The Hypertext Transfer Protocol (HTTP) is a protocol which is a set of rules that describes how information is exchanged, that enables a client such as a web browser and a Web Server to communicate with each other.
HTTP is based on a request-response model. The browser opens a connection to the server and sends a request to the server. The server processes the request and generates a response, which it sends to the browser. The server then closes the connection.
This chapter provides a short introduction to a few HTTP basics. For more information on HTTP, see the IETF home page athttp://www.ietf.org/home.html.
This chapter has the following sections:
Sun Java System Web Server supports HTTP/1.1. The server is conditionally compliant with the HTTP/1.1 proposed standard, as approved by the Internet Engineering Steering Group (IESG), and the Internet Engineering Task Force (IETF) HTTP working group.
For more information on the criteria for being conditionally compliant, see the Hypertext Transfer Protocol -- HTTP/1.1 specification (RFC 2616) at http://www.ietf.org/rfc/rfc2616.txt.
A request from a browser to a server includes the following information:
A browser can request information using a number of methods. The commonly used methods are:
GET — Requests the specified resource, such as a document or image
HEAD — Requests only the header information for the document
POST — Requests that the server accept some data from the browser, such as form input for a CGI program
PUT — Replaces the contents of a server’s document with data from the browser
The browser can send headers to the server. Most of these request headers are optional. This section lists some of the commonly used request headers.
File types the browser can accept.
Used if the browser wants to authenticate itself with a server. Information such as the user name and password are included.
Name and version of the browser software.
URL of the document.
Internet host and port number of the resource being requested.
If the browser has made a POST or PUT request, it sends data after the blank line following the request headers. If the browser sends a GET or HEAD request, no data exists to send.
The server’s response includes the following:
The server sends back a status code, which is a three-digit numeric code. The five categories of status codes are:
100-199 code indicate a provisional response.
200-299 code indicate a successful transaction.
300-399 code indicate the requested resource should be retrieved from a different location.
400-499 code indicate an error was caused by the browser.
500-599 code indicate a serious error occurred in the server.
The following table lists some common status codes.
Status Code |
Meaning |
---|---|
200 |
The Request has succeeded for the method used (GET, POST, HEAD). |
201 |
The request has resulted in the creation of a new resource reference by the returned URI. |
206 |
The server has sent a response to byte range requests. |
302 |
Found. Redirection to a new URL. The original URL has moved. This result is not an error. Most browsers will get the new page. |
304 |
Use a local copy. If a browser already has a page in its cache, and the page is requested again, some browsers such as Netscape Navigator relay to the web server the “last-modified” timestamp on the browser’s cached copy. If the copy on the server is not newer than the browser’s copy, the server returns a 304 code instead of returning the page, reducing unnecessary network traffic. This result is not an error. |
400 |
Sent if the request is not a valid HTTP/1.0 or HTTP/1.1 request. For example HTTP/1.1 requires a host to be specified either in the Host header or as part of the URI on the request line. |
401 |
Unauthorized. The user requested a document but did not provide a valid user name or password. |
403 |
Forbidden. Access to this URL is forbidden. |
404 |
Not found. The document requested is not on the server. This code can also be sent if the server is configured to protect the document for unauthorized personnel. |
408 |
If the client starts a request but does not complete it within the keep-alive timeout configured in the server, then this response will be sent and the connection closed. The request can be repeated with another open connection. |
411 |
The client submitted a POST request with chunked encoding, which is of variable length. However, the resource or application on the server requires a fixed length - a Content-Length header to be present. This code tells the client to resubmit its request with Content-Length. |
413 |
Some applications, for example, certain NSAPI plug-ins cannot handle very large amounts of data, so returns this error code. |
414 |
The URI is longer than the maximum the web server is willing to serve. |
416 |
Data was requested outside the range of a file. |
500 |
A server-related error occurred. The server administrator must check the error log in the server. |
503 |
Sent if the quality of service mechanism was enabled and bandwidth or connection limits were attained. The server then serves requests with that code. |
The response headers contain information about the server and the response data. This section lists some common response headers.
Name and version of the web server
Current date in Greenwich Mean Time
Date when the document was last modified
Date when the document expires
Length of the data that follows (in bytes)
MIME type of the data that follows
Used during authentication and includes information that tells the browser software what information is necessary for authentication such as user name and password
The server sends a blank line after the last header. It then sends the response data such as an image or an HTML page.