HyperText Transfer Protocol (HTTP)
HyperText Transfer Protocol (HTTP)
Introduction
HyperText Transfer Protocol (HTTP) is the application-layer protocol used for transferring web pages and other web resources on the World Wide Web (WWW).
It defines how a web browser (client) communicates with a web server to request and receive web pages.
HTTP follows the client–server paradigm, where:
- The client sends an HTTP request.
- The server processes the request and sends an HTTP response.
HTTP uses the services of the TCP protocol, which provides reliable and connection-oriented communication.
Definition
HTTP (HyperText Transfer Protocol) is an application-layer protocol that defines how web browsers and web servers communicate to retrieve and transfer web pages over the Internet.
Features of HTTP
- Application-layer protocol
- Uses the client–server model
- Uses TCP for reliable communication
- Default server port number: 80
- Client uses a temporary (ephemeral) port number
- Supports request–response communication
Working of HTTP
The communication between a client and a server follows these steps:
- The client (browser) establishes a TCP connection with the server.
- The client sends an HTTP request.
- The server processes the request.
- The server sends an HTTP response containing the requested web page or resource.
- The TCP connection is closed or kept open depending on the connection type.
HTTP Communication
Web Browser (Client) | HTTP Request | v Web Server | HTTP Response | v Web Browser
HTTP Uses TCP
HTTP relies on Transmission Control Protocol (TCP) because TCP provides:
- Reliable communication
- Connection-oriented service
- Error control
- Ordered delivery of data
Before any HTTP communication:
- A TCP connection must be established.
After communication:
- The TCP connection is terminated or kept alive.
HTTP Connections
HTTP supports two types of TCP connections:
- Nonpersistent Connection
- Persistent Connection
1. Nonpersistent Connection
Definition
In a nonpersistent connection, a separate TCP connection is established for each HTTP request and response.
This was the default behavior in HTTP/1.0.
Working
For every requested object:
- Open TCP connection
- Send HTTP request
- Receive HTTP response
- Close TCP connection
The same process is repeated for every object.
Example
Suppose a web page contains:
- One HTML file
- One image
The browser requires:
- One TCP connection for the HTML page
- Another TCP connection for the image
Total:
2 TCP connections
Example
Advantages
- Simple implementation
- Each request is independent
Disadvantages
- High communication overhead
- Repeated connection establishment and termination
- More memory and buffer usage
- Increased response time
2. Persistent Connection
Definition
In a persistent connection, one TCP connection is used for multiple HTTP requests and responses.
This is the default behavior in HTTP/1.1.
Working
- Establish one TCP connection.
- Send multiple HTTP requests.
- Receive multiple HTTP responses.
- Close the connection only after all objects are transferred or when a timeout occurs.
Example
Suppose a web page contains:
- One HTML file
- One image
Only one TCP connection is established.
The browser requests:
- HTML page
- Image
using the same connection.
Example
Figure shows the same scenario as in Example of non persistent connection, but using a persistent connection.Only one connection establishment and connection termination is used, but the request for the image is sent separately.
Advantages
- Reduced overhead
- Faster communication
- Saves bandwidth
- Lower memory usage
- Better server performance
Disadvantages
- Connection remains open for a longer time.
- Requires timeout management.
Comparison of Nonpersistent and Persistent Connections
| Feature | Nonpersistent Connection | Persistent Connection |
|---|---|---|
| TCP Connection | One per request | One for multiple requests |
| HTTP Version | Default in HTTP/1.0 | Default in HTTP/1.1 |
| Overhead | High | Low |
| Speed | Slower | Faster |
| Resource Usage | More | Less |
| Suitable For | Small transfers | Multiple web objects |
Why Persistent Connections are Preferred
Persistent connections:
- Reduce the number of TCP handshakes.
- Save transmission time.
- Reduce server workload.
- Improve web browsing performance.
Therefore, HTTP/1.1 uses persistent connections by default.
HTTP Security
HTTP per se does not provide security. However, as we show in Chapter 10, HTTP can be run over the Secure Socket Layer (SSL). In this case, HTTP is referred to as HTTPS.HTTPS provides confidentiality, client and server authentication, and data integrity.
Summary
HTTP (HyperText Transfer Protocol) is the application-layer protocol used to transfer web pages between a web browser and a web server. It follows the client–server model and uses TCP for reliable communication. HTTP supports two types of connections: nonpersistent connections, where a new TCP connection is created for every request, and persistent connections, where multiple requests are served using a single TCP connection. Persistent connections reduce overhead and improve communication efficiency, making them the default in HTTP/1.1.


Comments
Post a Comment