Java Reference
In-Depth Information
HTTP headers provide many important elements of the browsing experience. For exam-
ple, HTTP headers allow browsers to know length and type of data they are displaying. They
also allow pages to be secure and can prompt for user and password information. Some of the
specific types of information that can be found in the HTTP headers are summarized here:
• User authentication
• Data type
• Data length
• Cookies to maintain state
This topic covers each of these uses for headers. HTTP request headers will be exam-
ined first.
HTTP Request Headers
HTTP request headers are sent as part of the HTTP request. These headers tell the web
server nearly everything about the request. The GET request is made up entirely of head-
ers. The POST request contains an extra block of data, immediately after the headers that
contain the posted arguments.
Listing 1.3 shows a typical HTTP request.
Listing 1.3: Typical Request Headers
GET /1/1/typical.php HTTP/1.1
Accept: */*
Accept-Language: en
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en)
AppleWebKit/418 (KHTML, like Gecko) Safari/417.9.3
Connection: keep-alive
Host: www.httprecipes.com
There are really two parts to the headers: the first line and then the rest of the header
lines. The first line, which begins with the request type, is the most important line in the
header block, and it has a slightly different format than the other header lines. The request
type can be GET , POST , HEAD , or one of the other less frequently used headers. Browsers
will always use GET or POST . Following the request type is the file that is being requested.
In the above request, the following URL is being requested:
http://www.httprecipes.com/1/1/typical.php
Search WWH ::




Custom Search