Team LiB
Previous Section Next Section

What Comes Back: Server Response Codes

When you execute an HTTP method such as GET or POST against a Web server, the results of that method are returned with the first line of the server's response, including a three-digit status code. Here is a sample server response:

HTTP/1.1 200 OK

The first part of the response, HTTP/1.1, shows the type of protocol, and the 200 OK is the server response code. There are five basic types of server response codes organized by their code numbers:

  • 100199: General information These status codes are part of HTTP 1.1 only and are rarely used.

  • 200299: Successful client request The most common status code in the 200 range is the following:

    • 200OK The request was successful and the response from the server will contain the requested data.

  • 300399: Request was redirected to another location Further action by the browser is needed (that is, the browser should transparently fetch the content from the new location). The most common status codes in the 300 range are the following:

    • 301 Moved Permanently This indicates that the content has been moved to a new, permanent location. In the server's response to the client, the LOCATION header will contain the new URL where the content should be retrieved.

    • 307 Moved Temporarily This indicates that the content has been moved to a new, temporary location. In the server's response to the client, the LOCATION header will contain the new URL where the content should be retrieved.

  • 400499: Error with client request This indicates that for some reason the server was unable to process the client's request. Reasons can vary from lack of authentication to URLs that are too long. The most common status codes in the 400 range are the following:

    • 401 Unauthorized This indicates that the request lacked the correct authorization to supply the requested document. When a 401 status code is sent to the browser, the browser should prompt the user for the user's credentials.

    • 404 Not Found This indicates that the content being requested wasn't located at the specified URL.

  • 500599: Server-side errors This indicates that a server-side error has occurred. The most common status codes in the 500 range are the following:

    • 500 Internal Server Error This indicates that a server-side program (think CGI script) crashed.

    • 503 Service Unavailable This indicates that the service is temporarily offline and will be restored at a future point.

    Team LiB
    Previous Section Next Section