AJAX - The Complete Reference

(avery) #1

PART IV


Appendix B: HTTP 1.1 Reference 593


programs can detect things such as the browser being used, the particular types of images
supported by the browser, the language of the browser such as French, English, or Japanese,
and so on. Common HTTP 1.1 request headers and an example or two for each are shown
in Table B-5.

NNOT EOTE Some of the request headers seem very familiar because they constitute the same environment
variables that you can access from within a server-side programming environment. It should be
clear how that information is obtained.

Request Header Description Examples
Accept Indicates the data types accepted
by the requestor. An entry of */*
indicates anything is accepted.
Some browsers will indicate a
preference for a particular form
of content using a q-rating value.
When omitted, a value is assumed
to have a q-rating of 1, the highest
value. Values below 1 suggest less
preference for a particular content
form. Using an Accept header with
MIME types and “q” parameters, a
client may negotiate for a particular
form of content. For example, a
requesting client may indicate it
prefers PNG images over JPEGs so
the server may decide to send one
format or another. This concept of
content negotiation is actually quite
old and supported either inherently
or via add-ons in most Web servers;
however, it is rarely employed by
Web developers.

Accept: text/xml,
application/xml,
application/xhtml+xml,
text/html;q=0.9,
text/plain;q=0.8,
image/png,*/*;q=0.5

Accept-Charset Indicates the character set that is
accepted by the browser, such as
ASCII or foreign character encodings.
As with the Accept header, “q”
parameters may be used.

Accept-Charset: iso-8859-1,
utf-8, *

Accept-Encoding Instructs the server on what
type of encoding the browser
understands. Typically, this field is
used to indicate to the server that
compressed data can be handled.
“q” parameters are allowed but are
rarely used with this header.

Accept-Encoding: gzip,
deflate

TABLE B-5 HTTP 1.1 Request Headers
Free download pdf