HTTP Request Header Overview
HTTP client programs (such as browsers) must specify the request type (usually get or post) when sending requests to the server ). If necessary, the customer program can also choose to send other request headers. Most request headers are not required, except Content-Length. Content-Length must appear for post requests.
The following are some of the most common request headers:
Accept: the MIME type acceptable to the browser.
Accept-charset: the acceptable character set of the browser.
Accept-encoding: The data encoding method that the browser can decode, such as gzip. Servlet can return gzip-encoded HTML pages to a browser that supports gzip. In many cases, this can reduce the download time by 5 to 10 times.
Accept-language: the type of language that the browser wants to use when the server can provide more than one language version.
Authorization: authorization information, usually displayed in the response to the www-Authenticate header sent by the server.
Connection: Indicates whether a persistent connection is required. If the servlet sees that the value here is "keep-alive", or the request uses HTTP 1.1 (HTTP 1.1 performs a persistent connection by default), it can take advantage of the advantages of persistent connections, when a page contains multiple elements (such as an applet or image), the download time is significantly reduced. To achieve this, the servlet needs to send a Content-Length header in the response. The simplest method is to write the content into bytearrayoutputstream first, then, calculate the size of the content before writing it.
Content-Length: the length of the Request Message Body.
COOKIE: This is one of the most important request header information. For more information, see the following section in cookie processing.
From: the e-mail address of the Request sender, which is used by some special Web client programs and not used by the browser.
HOST: host and port in the initial URL.
If-modified-since: it is returned only when the requested content is modified after the specified date. Otherwise, the 304 "not modified" response is returned.
Pragma: specifying the "no-Cache" value indicates that the server must return a refreshed document, even if it is a proxy server and has a local copy of the page.
Referer: contains a URL from which you can access the current requested page.
User-Agent: browser type. This value is useful if the content returned by the servlet is related to the browser type.
UA-pixels, UA-color, UA-OS, UA-CPU: non-standard request headers sent by some versions of IE, indicating screen size, color depth, operating system, and cputype.
For more information about HTTP headers, see http://www.w3.org/protocols.