HTTP Message Flow and Message Parts - Part 1 of Chapter 3 from HTTP: The Definitive Guide (4/7) | WebReference

HTTP Message Flow and Message Parts - Part 1 of Chapter 3 from HTTP: The Definitive Guide (4/7)

To page 1To page 2To page 3current pageTo page 5To page 6To page 7
[previous] [next]

HTTP: The Definitive Guide, Chapter 3: HTTP Messages

Start Lines

All HTTP messages begin with a start line. The start line for a request message says what to do. The start line for a response message says what happened.

Request line

Request messages ask servers to do something to a resource. The start line for a request message, or request line, contains a method describing what operation the server should perform and a request URL describing the resource on which to perform the method. The request line also includes an HTTP version tells the server what dialect of HTTP the client is speaking.

All of these fields are separated by whitespace. In Figure 3-5a, the request method is GET, the request URL is /test/hi-there.txt, and the version is HTTP/1.1. Prior to HTTP/1.0, request lines were not required to contain an HTTP version.

Response line

Response messages carry status information and any resulting data from an operation back to a client. The start line for a response message, or response line, contains the HTTP version that the response message is using, a numeric status code, and a textual reason phrase describing the status of the operation.

All these fields are separated by whitespace. In Figure 3-5b, the HTTP version is HTTP/1.0, the status code is 200 (indicating success), and the reason phrase is OK, meaning the document was returned successfully. Prior to HTTP/1.0, responses were not required to contain a response line.

Methods

The method begins the start line of requests, telling the server what to do. For example, in the line "GET /specials/saw-blade.gif HTTP/1.0," the method is GET.

The HTTP specifications have defined a set of common request methods. For example, the GET method gets a document from a server, the POST method sends data to a server for processing, and the OPTIONS method determines the general capabilities of a web server or the capabilities of a web server for a specific resource.

Table 3-1 describes seven of these methods. Note that some methods have a body in the request message, and other methods have bodyless requests.

Table 3-1: Common HTTP methods

MethodDescriptionMessage body?
GETGet a document from the server.No

HEAD

Get just the headers for a document from the server.

No

POST

Send data to the server for processing.

Yes

PUT

Store the body of the request on the server.

Yes

TRACE

Trace the message through proxy servers to the server.

No

OPTIONS

Determine what methods can operate on a server.

No

DELETE

Remove a document from the server.

No

Not all servers implement all seven of the methods in Table 3-1. Furthermore, because HTTP was designed to be easily extensible, other servers may implement their own request methods in addition to these. These additional methods are called extension methods, because they extend the HTTP specification.


To page 1To page 2To page 3current pageTo page 5To page 6To page 7
[previous] [next]

Created: January 13, 2003
Revised: January 13, 2003

URL: https://webreference.com/programming/http/chap3/1/4.html