[Previous] [Contents] [Next]

Status codes

HTTP status codes are used to classify responses to requests. The HTTP status code system is extensible, with a set of codes described in the standard that are "generally recognized in current practice." HTTP defines a status code as a three-digit number; the first digit is the class of response. The following list shows the five classes of codes defined by HTTP:

1xx

Informational. HTTP 1.0 reserves this class of code for future use. HTTP 1.1 uses codes in this class to indicate the request has been received by the server and that processing is continuing.

2xx

Success. The request was successfully received, and the action successfully performed. i.e.

200 OK: The information returned with the response is dependent on the method used in the request.

3xx

Redirection. When a response has a redirection code, the client needs to make a further request to actually get the specified resource. The URL of the actual resource is included in the response header field Location. When the status code is set to 301, the browser automatically makes the request for the URL specified in the Location header field. The use of the Location header field is discussed further in Chapter 5, and used in many examples throughout this tutorial.

301 Moved Permanently: permanent redirection

302 Moved Temporarily: temporary redirection

4xx

Client error. The request can't be processed due to bad syntax of the message, the sender is unauthorized or forbidden to access the resource, or the resource can't be found.

400 Bad Request

401 Unauthorized

403 Forbidden

404 Not Found

410 Gone

5xx

Server error. The server failed to fulfill an apparently valid request.

500 Internal Server Error

501 Not Implemented

503 Service Unavailable

550 Permission denied

The actual code used for a particular response is largely determined by the configuration of the web server, and not by a scripting environment that might create a web application. Some scripting environments allow the web developer to explicitly set these codes. For example, a script associated with a URL might simply set the response code to 501 to indicate the requested function hasn't been implemented.

[Previous] [Contents] [Next]