Java Reference
In-Depth Information
Listing 12-7. A Typical Server Response
HTTP/1.1 200 OK
Date: Mon, 23 Jun 2008 22:13:40 GMT
Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.5
Content-Location: index.html
Vary: negotiate,accept-language,accept-charset
TCN: choice
Last-Modified: Mon, 24 Sept 2007 01:12:03 GMT
ETag: "ec11-5b0-43ad74ee73ec0;44bbb82e73280"
Accept-Ranges: bytes
Content-Length: 49
Connection: close
Content-Type: text/html
<html>
<body>
Hello world!
</body>
</html>
The first line of an HTTP server's response is always the response status, consist-
ing of the server version, a numeric indication of status, and a human-readable status
string. A status code is always a three-digit number; the first digit indicates the class of
the response, and the second and third indicate details. Common classes are 200 , indi-
cating success, and 400 , indicating a client error that caused the server to be unable to
fulfill the request. Table 12-5 shows a list of common (but not all) HTTP status codes.
Following the response status are a series of headers; the actual meaning of each
header isn't as important now as understanding that each header has a name (such as
Date ) followed by a value ( Mon, 23 Jun 2008 22:13:40 GMT ). You may encounter some
headers such as Content-Length and Content-Type often when using HTTP; many others
may not be necessary for your work. Fortunately, the most common ones, such as the
Date , Content-Length , and Content-Type headers, are self-explanatory; they indicate the
date and time the server generated the response, how many bytes are in the response,
and the encoding method the server used to encode the response, respectively.
Finally, after the headers comes the object body of the response—in this case, a short
HTML document.
 
Search WWH ::




Custom Search