So far we’ve seen various presentations of the HTTP format, and examined the idea that there is a lot more information being transferred in web requests and responses than just what appears in the body of the response. The body is certainly the important bit and often is the meatiest, but the headers give key pieces of information, both in requests and responses, that allow client and server to communicate effectively. If you think of the body of the request being the birthday card with a cheque inside it, then the headers are the address, postmark and perhaps the “do not open until …” instruction on the outside, see Figure 5-1.
This additional information is how we get the body data to where it needs to go and how we instruct the target what to do with it.
Many of the headers you see in HTTP make sense both in requests and responses. Others might be specifc to either a request or a response. Here’s a sample set of real request and response headers from when I request my own site http://www.lornajane.net/ from a browser (I’m using Chrome):
Example request headers.
GET / HTTP/1.1 Host: www.lornajane.net Connection: keep-alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.19 (KHTML, like Gecko) Chrome/25.0.1323.1 ...