Skip to main content

HTTP request served by server

Short answer

HTTP is a stateless client-server protocol over TCP, using port 80 or 443. A client sends a request line like GET /index.html HTTP/1.1 with headers, and the server replies with a status line, headers, and body, such as HTTP/1.1 200 OK with the HTML page.

What is HTTP protocol? With an example explain how a request initiated by an HTTP client is served by an HTTP server.

HTTP (HyperText Transfer Protocol) is the application-layer protocol of the World Wide Web. It follows the client-server model: a client (browser) sends a request and a server sends a response. It uses TCP, port 80 (HTTPS, port 443). HTTP is stateless: the server does not remember earlier requests (cookies add state).

Example: user opens http://www.abc.com/index.html

  1. The browser asks DNS for the IP address of www.abc.com (say 10.1.1.5).
  2. The browser opens a TCP connection to 10.1.1.5 port 80 (three-way handshake).
  3. The browser sends the request:
GET /index.html HTTP/1.1
Host: www.abc.com
User-Agent: Mozilla/5.0
Accept: text/html
Connection: keep-alive
  1. The server parses the request line, finds the file, and sends the response:
HTTP/1.1 200 OK
Date: Thu, 08 Oct 2026 10:00:00 GMT
Server: Apache
Content-Type: text/html
Content-Length: 2048

<html> ... </html>
  1. The browser reads the HTML. For each embedded object (images, CSS), it makes more requests, over the same connection if persistent (HTTP/1.1).
  2. The connection is closed (or kept for the next request) and the page is displayed.
Client                    Server
  |---- TCP handshake ---->|
  |---- GET /index.html -->|
  |<--- 200 OK + HTML -----|
  |---- GET /logo.png ---->|
  |<--- 200 OK + image ----|

Parts of a message

  • Request: request line (method, URL, version), headers, blank line, optional body. Methods: GET, POST, HEAD, PUT, DELETE.
  • Response: status line (version, code, phrase), headers, blank line, body.
  • Status codes: 1xx informational, 2xx success, 3xx redirection, 4xx client error (404), 5xx server error (500).

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Networks and Security chapter 6 questions →