The beginning of a request
2 Comments
Written by Robert on April 4, 2008 – 12:08 am
HTTP is basically a simple text protocol. The first line of a request specifies the request method (‘Get’, ‘Post’, …), the ‘resource’ and the protocol being used (HTTP/1.0 or HTTP/1.1). The next few lines are headers. These lines have a keyword that identifies the type of general header or request header, or entity header, and some data. There will be a blank line following these header data, and then possibly a request body (‘entity’).
General headers are used to specify properties of the transfer process. One example of a general header is the Connection header, which allows a client to specify that it wants to have its connection closed (Connection: close) as soon as the first response is complete. (Why would you want to do that? It is something messy relating to the use of proxy servers.) The Cache-Control header is a more complex example; a client requesting a resource that might be cached can use a Cache-Control header to specify constraints like the maximum age that it is prepared to accept for that resource. (An example might be a request for the headline page from a news source: you might accept a cached copy of page prepared two hours ago, but you wouldn’t want yesterday’s headlines.)
Request headers add supplementary information to a request or describe client capabilities. Examples include If-Modified-Since, Range, Accept-Language, Referer, and User-Agent. The header If-Modified-Since can be used with a ‘Get’ request for a static resource (fixed web page); this can save network traffic if the resource has not been modified as the server sends a short ‘not-modified’ response instead of a copy of the file. If a resource is large (e.g. a movie clip, audio clip or large image) it may be more convenient for a client to submit requests for successive segments of the data; a Range request allows a client to request a specified byte range from a resource.
An Accept-Language header specifies the language preferences that a user has specified in their browser’s properties dialog; if the server has a resource available in language variants, it should select the version that best matches the client’s requirement. If the client is requesting a resource by activating a hypertext link, the Referer header will contain the URI of the page containing that link. Finally, the User-Agent header will contain a text string identifying the browser that the client is using.
Popularity: 45% [?]

2 Trackback(s)