The Hyper Text Transfer Protocol (HTTP) is the client-server network protocol that has been in use by the World-Wide Web since 1990. Whenever you surf the web, your browser will be sending HTTP request messages for HTML pages, images, scripts and styles sheets. Web servers handle these requests by returning response messages that contain the requested resource.
The HTTP request message has a simple text based structure. For example, here is the the request message sent by Internet Explorer (IE) for this web page:
The first line of the message, known as the request line, contains:
The rest of the message consists of a set of name/value pairs, known as headers (See 2. HTTP Headers). HTTP clients use header values 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 or deflate algorithms (see 8. HTTP Compression).
The web server's response message has a similar structure, but is followed by the contents of the HTML page:
The first line, or status line, 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.
The next eight lines of text contain header values that describe the data 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. The response headers are terminated with a double CRLF (carriage return, line feed) and are followed by the contents of the requested resource.
Images are not directly embedded into web pages. Instead, they are specified as separate resources using HTML <img> tags:
Whenever the browser encounters an <img> tag, it checks to see if it has a valid copy of the image either loaded in memory or saved in its cache. If no suitable match is found, it sends out another HTTP request to retrieve it. This means that a web page will usually generate multiple HTTP requests; one for the HTML page and one for each of the images.
Clicking the Refresh button will redisplay this web page by sending HTTP requests to download the HTML of the page and its associated styles sheets and images.
Using HttpWatch with Example 1
The HttpWatch window will display about 8 entries. The first is for the page itself; the others are for the style sheets and images used by this page. Select the first entry and then click on the Stream tab to see the HTTP request and response messages described above.