AJAX - The Complete Reference

(avery) #1

596 Part IV: Appendixes


Custom Request Headers
It is possible to set your own custom HTTP request headers. Custom headers should use a
prefix X- to indicate they are extensions to the protocol. Beyond that, the header name and
allowed values are up to the imagination of the developer.

X-Debug: True
X-JavaScript-Version-Requested: 1.7
X-Cylon-Model: 6

Request Header Description Examples
Range Indicates a request for a particular
range of a file, such as a certain
number of bytes. The examples show
a request for the last 500 bytes of
a file as well as one requesting two
ranges of bytes. This type of request
will be found with content of type
multipart/byteranges.

Range: bytes=-500

Range: bytes=1036930-
1043528,1036928-1036929

Referer Indicates the URL of the document
from which the request originates (in
other words, the linking document).
This value might be empty if the user
has entered the URL directly rather
than by following a link. Some users
concerned with privacy may also
clear out their Referer headers, so
do not rely on its presence. Note the
misspelling. It is properly written in
the misspelled form.

Referer: http://ajaxref.com/
chapters/index.html

TE Indicates what transfer encodings
the client is willing to accept and
whether or not it will accept trailer
fields in chunked transfers. The
header value may contain the
keyword trailers and/or a list of
accepted encodings. As the header
overlaps with Accept-Encoding,
it appears not to be used in the
later form often.

TE: trailers

TE: gzip

User-Agent Indicates the type of browser
making the request. Very useful for
browser detection, but developers
should not trust it completely as it
is often falsified by clients for both
legitimate and nefarious reasons.

User-Agent: Mozilla/5.0
(Windows; U; Windows NT
5.1; en-US; rv:1.8.1.3)
Gecko/20070309
Firefox/2.0.0.3

TABLE B-5 HTTP 1.1 Request Headers (continued)
Free download pdf