AJAX - The Complete Reference

(avery) #1

PART IV


Appendix B: HTTP 1.1 Reference 597


Practically speaking, some Ajax libraries may send such headers for use by a back-end
environment to determine how to handle the request or simply for logging purposes to
understand if a request is triggered using Ajax or not.

X-Requested-By: Awesome-Ajax-Lib

You might also see the header being used to pass special request signatures, as
discussed in Chapter 7, to help improve Ajax request security.

X-Signature: QWxhBalTaRb3l1T3pvN

HTTP Responses


After receiving a request, a Web server attempts to process the request. The result of the
request is indicated by the first line of the response, which includes the following data:

HTTP-version status-code reason-string

where


  • HTTP-version is a version string, such as HTTP/1.1.

  • status-code is a string containing a numeric code, such as 200 or 404 , indicating
    the status of the response.

  • reason-string is the text string, such as OK or Not Found, explaining the numeric
    status code.


For a successful query, a status line might read as follows:

In the case of an error, the status line might read:

The status codes that are found in the response line are grouped in five categories, as
summarized in Table B-6.
The specific nature of each response code is detailed in Table B-7. Response codes not
listed in this table but within an allowed range shown in Table B-6 are treated as a general
type of the class of response. For example, a 499 response would be a client error, while 384
would be a redirection of some sort. While the specification may be clear about this
interpretation, what actually happens, particularly in the case of a redirection when such
generic responses are received, is not defined nor obvious.
Free download pdf