Suppose Jake clicks on this link on a page:
Figure 1. Superdogs
Here’s the conversation between the browser and the server.
Client: GET superdogs.html HTTP/1.1 Host: www.evildoom.com Server: HTTP/1.1 200 OK Last-Modified: Mon, 25 Dec 2006 22:22:22 GMT Content-Type: text/html (Web page content)
Figure 2. HTTP conversation
The HTTP response consists of three parts:
- Response status (line 6 in Figure 2)
- Response headers (lines 7 and 8)
- Data (line 9 and beyond)
The status is the first line of the response, like
HTTP/1.1 200 OK. There are other codes. For example, what if the server can’t find the data the browser asked for? The server will send 404, a code meaning “page not found.”
The third piece – the data – is the content the client wants. We’ll talk more about that on the next page.
The response headers describe the server, the data, or the request. For instance, the header
Last-Modified tells the browser when the resource (
superdogs.html) was last changed. The header
Server tells the browser what the server is (e.g.,
Server: Apache/126.96.36.199 (Unix)). The header
Content-Length tells the browser how much data to expect.
One of the most important headers is
Content-Type. This tells the browser what type of data it is being sent. Text? An image? A sound? An OpenOffice spreadsheet? The browser will look at the type to decide how to show the data to the user.
HTTP uses the Internet media type standard to indicate content type. A typical type indicator has two parts. For instance,
text/plain means that the content is just plain text.
text/html means the content is in the HTML language, which we’ll see on the next page.
image/jpeg means the content is an image in the JPEG format.
image/png means that the content is an image as well, but in the PNG format.
audio/wav means that the content is sound, in the WAV format.
The Internet media type standard is maintained by the IANA (Internet Assigned Numbers Authority). It’s a standards group, like the W3C.
When a user sees a Web page in a browser, s/he doesn’t see the headers. But the headers can affect the way the content is shown. For example, suppose a browser gets this content:
If the content type header is:
The browser will interpret the data as HTML, and the user will see:
But if the header is:
The browser will interpret the data as text, and the user will see: