Webmaster in a Nutshell

Previous Chapter 19
HTTP Headers
Next
 

19.2 Client Request Headers

Client header data communicates the client's configuration and preferred document formats to the server. Request headers are used in a client message to provide information about the client.

Accept

Accept: type/subtype [; q=qvalue]

Specifies media types that the client prefers to accept. Multiple media types can be listed separated by commas. The optional qvalue represents on a scale of 0 to 1 an acceptable quality level for accept types. See Chapter 20, Media Types and Subtypes, for a listing of some commonly-accepted media types.

Accept-Charset

Accept-Charset: character_set [; q=qvalue]

Specifies the character sets that the client prefers. Multiple character sets can be listed separated by commas. The optional qvalue represents on a scale of 0 to 1 an acceptable quality level for non-preferred character sets.

Accept-Encoding

Accept-Encoding: encoding_types

Specifies the encoding schemes that the client can accept, such as compress or gzip. Multiple encoding schemes can be listed, separated by commas. If no encoding types are listed, then none are acceptable to the client.

Accept-Language

Accept-Language: language [; q=qvalue]

Specifies the languages that the client prefers. Multiple languages can be listed separated by commas. The optional qvalue represents on a scale of 0 to 1 an acceptable quality level for non-preferred languages. Languages are written with their two-letter abbreviations (e.g., en for English, de for German, fr for French, etc.)

Authorization

Authorization: scheme credentials

Provides the client's authorization to access data at a URI. When a requested document requires authorization, the server returns a WWW-Authenticate header describing the type of authorization required. The client then repeats the request with the proper authorization information.

The authorization scheme generally used in HTTP is BASIC, and under the BASIC scheme the credentials follow the format username:password encoded in base64. For example, for the username of "webmaster" and a password of "zrma4v," the authorization header would look like this:

Authorization: BASIC d2VibWFzdGVyOnpycW1hNHY=

The value decodes into webmaster:zrma4v.

Cookie

Cookie: name=value

Contains a name/value pair of information stored for that URL. Multiple cookies can be specified, separated by semicolons. For browsers supporting Netscape persistent cookies; not included in the HTTP standard. See Chapter 12, Cookies, for more information.

From

From: email_address

Gives the email address of the user executing the client.

Host

Host: hostname[: port]

Specifies the host and port number of the URI. Clients must supply this information in HTTP 1.1, so servers with multiple hostnames can easily differentiate between ambiguous URLs.

If-Modified-Since

If-Modified-Since: date

Specifies that the URI data is to be sent only if it has been modified since the date given as the value of this header. This is useful for client-side caching. If the document has not been modified, the server returns a code of 304, indicating that the client should use the local copy. The specified date should follow the format described under the Date header.

If-Match

If-Match: entity-tag

A conditional requesting the entity only if it matches the given entity tags (see the ETag entity header). An asterisk (*) matches any entity, and the transaction continues only if the entity exists.

If-None-Match

If-None-Match: entity_tag

A conditional requesting the entity only if it does not match any of the given entity tags (see the ETag entity header). An asterisk (*) matches any entity; if the entity doesn't exist, the transaction continues.

If-Range

If-Range: entity_tag | date

A conditional requesting only the portion of the entity that is missing if it has not been changed, and the entire entity if it has. Must be used in conjunction with a Range header. Either an entity tag or a date can be used to identify the partial entity already received; see theDate header for information on the format for dates.

If-Unmodified-Since

If-Unmodified-Since: date

Specifies that the URI data is to be sent only if it has not been modified since the given date. The specified date should follow the format described under the Date header.

Max-Forwards

Max-Forwards: n

Limits the number of proxies or gateways that can forward the request. Useful for debugging with the TRACE method, avoiding infinite loops.

Proxy-Authorization

Proxy-Authorization: credentials

Used for a client to identify itself to a proxy requiring authorization.

Range

Range: bytes= n-m

Specifies the partial range(s) requested from the document. Multiple ranges can be listed, separated by commas. If the first digit in the comma-separated byte range(s) is missing, the range is assumed to count from the end of the document. If the second digit is missing, the range is byte n to the end of the document. The first byte is byte 0.

Referer

Referer: url

Gives the URI of the document that refers to the requested URI (i.e., the source document of the link).

User-Agent

User-Agent: string

Gives identifying information about the client program.


Previous Home Next
General Headers Book Index Server Response Headers

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell