AJAX - The Complete Reference

(avery) #1

588 Part IV: Appendixes


where:


  • HTTP-Method is an HTTP request method such as GET or POST

  • Resource-identifier is a relative URL to correspond to the resource to fetch

  • HTTP-version indicates the version of HTTP in use, such as 1.0 or 1.1


A specific example of a valid HTTP request line is shown here:

NNOT EOTE You may wonder why the complete URL for the requested resource is not shown in the
request. It isn't necessary in most cases, except when using a proxy server. The use of a relative
URL in the header is adequate. The server knows where it is; it just needs to know what
document to get from its own file tree. In the case of using a proxy server, which requests a
document on behalf of a client, a full URL is passed to it that is later made relative by the proxy.

HTTP Methods


HTTP 1.1 supports seven primary methods. While most Ajax developers will likely be
satisfied using GET, POST, and an occasional HEAD request, there are more possibilities,
as summarized in Table B-1.

TABLE B-1 Summary of HTTP 1.1 Request Methods

Method Description
GET Returns the object specified by a passed identifier. Sometimes data may be
passed within the identifier of the resource requested as specified by a set of
name-value pairs called a query string; otherwise no message body required.
HEAD Returns information about the object specified by the identifier, such as last
modification data, but does not return the actual object. No message body
required.

OPTIONS Returns information about the capabilities supported by a server if no location is
specified or the possible methods that can be applied to the specified object. No
message body required.

POST Sends information to the address indicated by the identifier. Posted data is
found in the message body.

PUT Sends message body data to the server and writes it to the address specified by
the identifier overwriting any previous content. Often disallowed by servers.

DELETE Removes the file specified by the identifier; generally disallowed for security
reasons. No message body required.

TRACE Provides diagnostic information by allowing the client to see what is being
received on the server. No message body required.
Free download pdf