Headers are name/value pairs that appear in both request and response messages. The name of the header is separated from the value by a single colon. For example, this line in a request message:
provides a header called User-Agent whose value is Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1). The purpose of this particular header is to supply the web server with information about the type of browser making the request. A complete definition of this and other commonly encountered HTTP headers can be found in the HTTP 1.1 specification.
Some web applications use custom headers to add comments or annotations to an HTTP message. The convention is to prefix the header name with X- to indicate that it is non-standard. In the previous example, the HTTP response message from this web server set an X-AspNet-Version header to indicate which version of ASP.NET it is running.
Clicking the Get Current Time button requests an updated copy of the following image:
HTTP clients use headers in the request message to identify themselves and control how content is returned. If you are using IE, you will have seen the following headers sent with the request in Example 2:
This header indicates that the browser will accept all types of content.
The browser prefers British English content.
The browser can handle gzip or deflate compressed content
The browser is requesting the use of persistent TCP connections.
HTTP/1.1 requires that the host name is supplied with every request so that multiple domains can be hosted on a single IP address.
This is supplied by the browser to indicate if the current request was the result of a link from another web page. The server may use this information to gather usage statistics or to track which web sites have links to a page.
This identifies the browser is Internet Explorer Version 6 running on Windows XP.
HTTP servers use headers in the response message to specify how content is being returned and how it should be handled. If you are using IE, you will have seen the following headers returned with the image in Example 2:
This header indicates whether the resource may be cached by the browser or any immediate caches. The value no-cache disables all caching. (See 5. Caching for more information)
This header contains the length in bytes of the resource (i.e. the gif image) that follows the headers.
The content is in GIF format.
This is the current date and time on the web server.
The Expires header specifies when the content should be considered to be out of date. The value -1 indicates that the content expires immediately and would have to be re-requested before being displayed again.
The browser may be connecting to the server via HTTP/1.0 proxies or caches, that do not support the Cache-Control header. Setting Pragma to no-cache header prevents HTTP/1.0 caches from storing the content.
The web server is an IIS 6 web server.
The web server is running ASP.NET 2.0
The web server is running ASP.NET.
<< Previous (1. Introduction to HTTP) Next >> (3. Status codes and Errors)
Copyright © 2002 - 2008 Simtec Limited, All Rights Reserved