HyperText Transfer Protocol
(HTTP)
Client-Server Communication
Protocol for the Web
Introduction to HTTP
• • HTTP defines how client-server programs
communicate over the web.
• • Client sends an HTTP request; server sends
an HTTP response.
• • HTTP uses TCP (port 80) and is connection-
oriented and reliable.
HTTP Request-Response Behaviour
• • Client sends an HTTP request to the web
server.
• • Server (e.g., Apache) processes and returns
an HTTP response.
• • The communication uses TCP as the
transport layer.
• [Insert Diagram: HTTP request-response
behaviour]
Web Documents
• • Static Documents: Fixed content stored on
the server.
• • Dynamic Documents: Created by server-side
programs upon request.
• • Active Documents: Executed on client-side,
e.g., Java applets.
Nonpersistent Connections
• • One TCP connection for each
request/response.
• Steps:
• 1. Client opens a TCP connection and sends a
request.
• 2. Server sends response and closes
connection.
• 3. Client reads data and closes the connection.
Persistent Connections
• • Server keeps the connection open for
multiple requests.
• • Reduces overhead of opening new
connections.
• • Closed on timeout or client request.
• • Sender includes data length with each
response.
• [Insert Diagram: Persistent Connection]
HTTP Message Formats
• Two types of messages:
• 1. Request Message
• 2. Response Message
• Both include:
• • Start line
• • Header lines
• • Blank line
• • Body (optional)
Request Message Format
• • Request Line: Method URL Version
• Example: GET /[Link] HTTP/1.1
• • Method: Defines type (GET, POST, etc.)
• • URL: Identifies web resource
• • Version: HTTP version (usually 1.1)
Response Message Format
• • Status Line: Version Status-Code Phrase
• Example: HTTP/1.1 200 OK
• • Version: HTTP version
• • Status Code: 3-digit code (200, 404, etc.)
• • Phrase: Text form of status code
• [Insert Diagram: Response Message Format]
Web Caching and Proxy Servers
• • Proxy server stores copies of responses for
recent requests.
• • Reduces load on original server and network
traffic.
• • Acts as both client and server.
• • Sends stored responses for repeated
requests.
• [Insert Diagram: Proxy Server Example]
Advantages of Proxy Servers
• • Faster access to frequently requested data.
• • Reduces bandwidth usage.
• • Enhances security and control.
• • Filters unwanted content.
Summary
• • HTTP is a client-server communication
protocol.
• • Uses TCP and supports persistent and
nonpersistent connections.
• • Defines request and response message
formats.
• • Proxy servers improve efficiency and speed.
References
• • Computer Networks – Behrouz A. Forouzan
• • Department Notes / Study Material