start page | rating of books | rating of authors | reviews | copyrights

Book HomeWebmaster in a Nutshell, 3rd EditionSearch this book

17.2. Server Responses and Status Codes

The server's response to a client request is grouped into three parts. The first line is the server response line, which contains the HTTP version number, a three-digit number indicating the status of the request (called a server response code or status code), and a short phrase describing the status. The response line is followed by the header information and an entity body if there is one.

Status codes are typically generated by web servers. However, they can also be generated by CGI scripts that bypass the server's precooked headers and supply their own. Status codes are grouped as follows.

Code range

Response meaning

100-199

Informational

200-299

Client request successful

300-399

Client request redirected, further action necessary

400-499

Client request incomplete

500-599

Server errors

HTTP defines only a few specific codes in each range, although servers may define their own as needed. If a client receives a code it does not recognize, it should understand its basic meaning from its numerical range. While most web browsers handle codes in the 100-, 200-, and 300-range silently, some error codes in the 400- and 500-range are commonly reported back to the user (e.g., "404 Not Found").

17.2.1. Informational

A response in the range of 100-199 is informational, indicating that the client's request was received and is being processed.

100 Continue
The initial part of the request has been received and the client may continue with its request.

101 Switching Protocols
The server is complying with a client request to switch protocols to the one specified in the Upgrade header field.

17.2.2. Client Request Successful

A response in the range of 200-299 means that the client's request was successful.

200 OK
The client's request was successful, and the server's response contains the requested data.

201 Created
This status code is used whenever a new URI is created. With this result code, the Location header is given by the server to specify where the new data was placed.

202 Accepted
The request was accepted but not immediately acted upon. More information about the transaction may be given in the entity body of the server's response. Note that there is no guarantee that the server will actually honor the request, even though it may seem like a legitimate request at the time of acceptance.

203 Non-Authoritative Information
The information in the entity header is from a local or third-party copy and not from the original server.

204 No Content
A status code and header are given in the response, but there is no entity body in the reply. On receiving this response, browsers should not update their document view. This is a useful code for an imagemap handler to return when the user clicks on useless or blank areas of an image.

205 Reset Content
The browser should clear the form used for this transaction for additional input. Appropriate for data-entry CGI applications.

206 Partial Content
The server is returning partial data of the size requested. Used in response to a request specifying a Range header. The server must specify the range included in the response with the Content-Range header.

17.2.3. Redirection

A response code in the 300-399 range indicates that the request was not performed, and the client needs to take further action for a successful request.

300 Multiple Choices
The requested URI refers to more than one resource. For example, the URI could refer to a document that has been translated into many languages. The entity body returned by the server could have a list of more specific data about how to choose the correct resource.

301 Moved Permanently
The requested URI is no longer used by the server, and the operation specified in the request was not performed. The new location for the requested document is specified in the Location header. All future requests for the document should use the new URI.

302 Found
The requested URI temporarily has a new URI. The Location header points to the new location. If this is in response to a GET or a HEAD, the client should use the new URI to resolve the request immediately after receiving the response.

303 See Other
The requested URI can be found at a different URI (specified in the Location header) and should be retrieved by a GET on that resource.

304 Not Modified
This is the response code to an If-Modified-Since header, where the URI has not been modified since the specified date. The entity body is not sent, and the client should use its own local copy.

305 Use Proxy
The requested URI must be accessed through the proxy in the Location header.

307 Temporary Redirect
The requested URI has moved temporarily. The Location header points to the new location. Immediately after receiving this status code, the client should use the new URI to resolve the request, but the old URI should be used for all future requests.

17.2.4. Client Request Incomplete

A response code in the range of 400-499 means that the client's request was incomplete and may indicate further information is required from the client.

400 Bad Request
This response code indicates that the server detected a syntax error in the client's request.

401 Unauthorized
The result code is given along with the WWW-Authenticate header to indicate that the request lacked proper authorization, and the client should supply proper authorization when requesting this URI again.

402 Payment Required
This code is not yet implemented in HTTP. However, it may, one day, indicate that a payment is required to receive the document on the server.

403 Forbidden
The request was denied for a reason the server does not want to (or has no means to) indicate to the client.

404 Not Found
The document at the specified URI does not exist.

405 Method Not Allowed
This code is given with the Allow header and indicates that the method used by the client is not supported for this URI.

406 Not Acceptable
The URI specified by the client exists, but not in a format preferred by the client. Along with this code, the server provides the Content-Language, Content-Encoding, and Content-Type headers.

407 Proxy Authentication Required
The proxy server needs to authorize the request before forwarding it. Used with the Proxy-Authenticate header.

408 Request Time-out
This response code means the client did not produce a full request within some predetermined time (usually specified in the server's configuration), and the server is disconnecting the network connection.

409 Conflict
This code indicates that the request conflicts with another request or with the server's configuration. Information about the conflict should be returned in the data portion of the reply.

410 Gone
This code indicates that the requested URI no longer exists and has been permanently removed from the server.

411 Length Required
The server will not accept the request without a Content-Length header supplied in the request.

412 Precondition Failed
The condition specified by one or more If... headers in the request evaluated to false.

413 Request Entity Too Large
The server will not process the request because its entity body is too large.

414 Request-URI Too Long
The server will not process the request because its requested URI is too large.

415 Unsupported Media Type
The server will not process the request because its entity body is in an unsupported format.

416 Requested Range Not Satisfiable
The server detected a Range header that contained no valid values for the target. In addition, an If-Range header was omitted.

417 Expectation Failed
The condition specified in an Expect header could not be satisfied.

17.2.5. Server Errors

Response codes in the range of 500-599 indicate that the server encountered an error and may be unable to perform the client's request.

500 Internal Server Error
This code indicates that a part of the server (for example, a CGI program) has crashed or encountered a configuration error.

501 Not Implemented
This code indicates that the client requested an action that cannot be performed by the server.

502 Bad Gateway
This code indicates that the server (or proxy) encountered invalid responses from another server (or proxy).

503 Service Unavailable
This code means that the service is temporarily unavailable but should be restored in the future. If the server knows when it will be available again, a Retry-After header may also be supplied.

504 Gateway Time-out
This response is like 408 (Request Time-out) except that a gateway or proxy has timed out.

505 HTTP Version not supported
The server will not support the HTTP protocol version used in the request.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.