1. Introduction
The Hypertext Transfer Protocol (HTTP) is the client-server network protocol that has been used by the World Wide Web since 1990. Whenever you browse the web, your browser sends HTTP request messages for HTML pages, images, scripts, style sheets, fonts and data. Web servers handle these requests by returning response messages that contain the requested resource.
1.1 HTTP Request Message
An HTTP request message consists of a list of name/value pairs. For example, here is a simplified version of the request message sent by Google Chrome for this web page. This site uses HTTP/2, so the names are in lower case:
:authority: www.httpwatch.com
:method: GET
:path: /httpgallery/introduction/
:scheme: https
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
accept-encoding: gzip, deflate, br, zstd
accept-language: en-GB,en-US;q=0.9,en;q=0.8
priority: u=0, i
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36
The names starting with a colon are pseudo-headers that describe the request itself:
- :method is the HTTP method. (See 6. HTTP Methods for more information)
- :path is the path of the requested resource, including any query string
- :scheme and :authority give the scheme (https) and the host name of the web site
With HTTP/1.1, the same information is sent as a text request line, which also includes the version of HTTP being used, followed by a host header:
GET /httpgallery/introduction/ HTTP/1.1
host: www.httpwatch.com
HTTP/2 does not need a version number in each request because the version is agreed when the connection is set up (see 1.3 HTTP Versions below).
The rest of the message consists of name/value pairs known as headers (See 2. HTTP Headers). HTTP clients use header values to describe themselves and to control how the request is processed by the server. For example, the accept-encoding header indicates that the browser can handle content compressed using the gzip, deflate, br (Brotli) or zstd (Zstandard) algorithms (see 8. HTTP Compression).
1.2 HTTP Response Message
The web server's response message has a similar structure, but is followed by the contents of the HTML page. Here is the response from www.httpwatch.com:
:status: 200
cache-control: no-cache, no-store
content-encoding: br
content-type: text/html; charset=utf-8
date: Tue, 13 Oct 2026 11:03:19 GMT
last-modified: Tue, 13 Oct 2026 10:01:27 GMT
server: Microsoft-IIS/10.0
vary: Accept-Encoding
x-powered-by: ASP.NET
<!DOCTYPE html><html lang="en">...
The :status pseudo-header returns a status code from the server that indicates whether the request was successful (see 3. Status Codes and Errors). The value 200 is returned if the request was processed correctly and content is being returned to the client. With HTTP/1.1 this is sent as a status line that also contains the version and a short description, e.g. HTTP/1.1 200 OK.
The headers that follow describe the content and the way in which it is being returned to the client. For example, content-type has the value text/html because the page is in HTML format, and content-encoding shows that it was compressed with Brotli. There is no content-length header because the page is compressed as it is sent, so its final size is not known in advance. HTTP/2 marks the end of the content in the way it splits the response into frames, whereas HTTP/1.1 would send the page in a series of chunks, with a transfer-encoding: chunked header. The headers are followed by the contents of the requested resource.
Images are not directly embedded into web pages. Instead, they are specified as separate resources, for example using HTML <img> tags:
<img src="images/logo.png" width="50" height="50" alt="Logo">
Whenever the browser encounters an <img> tag, it checks whether it has a valid copy of the image either in memory or saved in its cache. If no suitable match is found, it sends another HTTP request to retrieve it. The same applies to the style sheets, scripts and fonts used by the page, so a single web page usually generates many HTTP requests: one for the HTML page and one for each of the other resources it uses.
1.3 HTTP Versions
The messages above were sent using HTTP/2. Today, most HTTPS sites, including this one, are accessed using HTTP/2 or HTTP/3 rather than the original text based HTTP/1.1 protocol:
| HTTP/1.1 | Sends each message as plain text over a TCP connection and handles one request at a time on each connection, so browsers open several connections to each server to download resources in parallel. Defined in RFC 9112. |
| HTTP/2 | Uses a binary format that multiplexes many requests and responses over a single TCP connection and compresses headers to save bandwidth. Defined in RFC 9113. |
| HTTP/3 | Runs over QUIC, a transport protocol built on UDP, which reduces connection set up time and avoids one lost packet holding up every request on the connection. Defined in RFC 9114. |
Although the way messages are transmitted is different, every version uses the same methods, status codes and headers, as defined in RFC 9110 (HTTP Semantics). So everything described in the HTTP Gallery applies whichever version your browser uses.
Example 1
Clicking the Refresh this page button will redisplay this web page by sending HTTP requests to download the HTML of the page and its associated style sheets, scripts and images.
Using HttpWatch with Example 1
- Open HttpWatch by pressing Ctrl+Shift+H, clicking the HttpWatch icon on the browser toolbar, or right-clicking the page and selecting HttpWatch
- Click on Record to start logging requests in HttpWatch
- Click on the Refresh this page button above
The HttpWatch window will display a number of entries. The first is for the page itself; the others are for the style sheets, scripts, fonts and images used by this page. Select the first entry and then click on the Headers or Stream tab to see the HTTP request and response messages described above.
