Cover by Lorna Jane Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Chapter 5. Headers

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.

Image Envelope with stamp, address and postmark
Figure 5-1. Image Envelope with stamp, address and postmark

Request and Response Headers

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required