HTTP

HTTP (HyperText Transfer Protocol) is the web's application-layer protocol:

HTTP communication occurs between a client process and a server process.

An object (HTML file, image, JavaScript, CSS file, etc.) is addressable by a single URL

HTTP/1.1 uses TCP as its underlying transport protocol:

TCP provides a reliable data transfer service to HTTP:

The server sends requested files to clients without storing any state information about the client:

Two different browsers may interpret a web page in somewhat different ways:

Non-persistent and persistent connections

The application developer needs to make an important decision:

HTTP/1.1 message format

HTTP specifications include the definitions of the HTTP message formats.

Two types of HTTP messages:

In HTTP/1.1, messages are written in ASCII text:

Request message

General format of an HTTP request message:

                  ┌──────────────────────────────────────────┐
Request line ─────│ method │ ␣ │ URL │ ␣ │ version │ cr │ lf │
             ┌────└──────────────────────────────────────────┘
             │    │ header field name │ ␣ │ value │ cr │ lf │
Header lines │    └─────────────────────────────────────────┘
             │    │ header field name │ ␣ │ value │ cr │ lf │
             └────└─────────┐───────────────────────────────┘
  Blank line ─────│ cr │ lf │
                  └─────────┘─────────────────────────────────────┐
                  │                                               │
 Entity body ─────│                                               │
                  │                                               │
                  └───────────────────────────────────────────────┘

After the header lines (and the additional CRLF) there is an entity body:

Example:

GET /somedir/page.html HTTP/1.1
Host: www.someschool.edu
Connection: close
User-agent: Mozilla/5.0
Accept-language: fr

The first line is the request line with three fields:

  1. method field (GET)
  2. URL field (/somedir/page.html)
  3. HTTP version field (HTTP/1.1)

Subsequent lines are the header lines:

Response message

General format of an HTTP response message:

                  ┌────────────────────────────────────────────┐
 Status line ─────│ version │ ␣ │ code │ ␣ │ message │ cr │ lf │
             ┌────└────────────────────────────────────────────┘
             │    │ header field name │ ␣ │ value │ cr │ lf │
Header lines │    └─────────────────────────────────────────┘
             │    │ header field name │ ␣ │ value │ cr │ lf │
             └────└─────────┐───────────────────────────────┘
  Blank line ─────│ cr │ lf │
                  └─────────┘─────────────────────────────────────┐
                  │                                               │
 Entity body ─────│                                               │
                  │                                               │
                  └───────────────────────────────────────────────┘

Example:

HTTP/1.1 200 OK
Connection: close
Date: Tue, 18 Aug 2026 15:44:04 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Tue, 18 Aug 2026 15:11:03 GMT
Content-Length: 6821
Content-Type: text/html

(data data data data data ...)

The first line is the status line with three fields:

  1. the protocol version (HTTP/1.1)
  2. a status code (200)
  3. a status message (OK)

Subsequent lines:

User-server interaction: cookies

Cookies (RFC 6265) can be used to create a user session layer on top of stateless HTTP.

A cookie has four components:

Web caching (web cache/proxy server)

A web cache (or proxy server, RFC 9111) is a network entity that satisfies HTTP requests on behalf of an origin web server.

The web cache has its own disk storage and keeps copies of recently requested objects in this storage.

A browser can be configured so that all the user's HTTP requests are first directed to the web cache.

A cache is both a server and a client at the same time:

The conditional GET

Caching introduces a new problem: the copy of an object residing in the cache may be stale.

HTTP has a mechanism that allows a cache to verify that its objects are up to date: conditional GET (RFC 9110).

An HTTP request message is a conditional GET message if:

Example:

HTTP/2

HTTP/2 goals:

HTTP/2:

Persistent TCP connections are used to reduce the number of sockets at the server:

HTTP/2 framing:

Compression of HTTP header fields:

The framing sublayer uses HPACK header compression:

Message prioritization:

Server push:

Previous Introduction to the application layer All ⏎ Next E-mail

A Kemar Joint