Every handler must return a status code. There are many possible codes, each of which is associated with a symbolic constant. The constants are defined by the Apache::Constants module if you are using Perl and the httpd.h
include file if you are using the C language.
Code
|
Constant (Nickname)
|
Description
|
---|
2XX Codes--Success |
200
|
HTTP_OK
(DOCUMENT_FOLLOWS)
|
The URI was found. Its contents follow.
|
201
|
HTTP_CREATED
|
The URI was created in response to a PUT.
|
202
|
HTTP_ACCEPTED
|
The request was accepted for processing at a later date.
|
203
|
HTTP_NON_AUTHORITATIVE
|
This is nonauthoritative mirrored information.
|
204
|
HTTP_NO_CONTENT
|
The request was successful, but there's no content to display.
|
206
|
HTTP_PARTIAL_CONTENT
(PARTIAL_CONTENT)
|
A portion of the document follows.
|
3XX Codes--Multiple Choices Available |
300
|
HTTP_MULTIPLE_CHOICES
(MULTIPLE_CHOICES)
|
There are multiple document choices. (Used in content negotiation.)
|
301
|
HTTP_MOVED_PERMANENTLY
(MOVED)
|
The document has permanently moved to a new URI.
|
302
|
HTTP_MOVED_TEMPORARILY
(REDIRECT)
|
The document has temporarily moved to a new URI.
|
304
|
HTTP_NOT_MODIFIED
(USE_LOCAL_COPY)
|
The document has not been modified since it was cached.
|
4XX Codes--Client-Side Errors |
400
|
HTTP_BAD_REQUEST
(BAD_REQUEST)
|
The request contains a syntax error.
|
401
|
HTTP_UNAUTHORIZED
(AUTH_REQUIRED)
|
The client did not provide correct authorization information.
|
402
|
HTTP_PAYMENT_REQUIRED
|
Payment is required. (Used in charging schemes.)
|
403
|
HTTP_FORBIDDEN
(FORBIDDEN)
|
The client is not allowed to access the document.
|
404
|
HTTP_NOT_FOUND
(NOT_FOUND)
|
The requested document does not exist.
|
405
|
HTTP_METHOD_NOT_ALLOWED
(METHOD_NOT_ALLOWED)
|
The request method (e.g., PUT) is not allowed here.
|
406
|
HTTP_NOT_ACCEPTABLE
|
The request is not acceptable.
|
407
|
HTTP_PROXY_AUTHENTICATION_REQUIRED
|
Proxy server must provide authentication.
|
408
|
HTTP_REQUEST_TIME_OUT
|
The client waited too long to complete the request.
|
410
|
HTTP_GONE
|
The requested document has been permanently removed.
|
412
|
HTTP_PRECONDITION_FAILED
(PRECONDITION_FAILED)
|
A conditional retrieval of the document has failed.
|
413
|
HTTP_REQUEST_ENTITY_TOO_LARGE
|
The client tried to PUT or POST data that was too long.
|
414
|
HTTP_REQUEST_URI_TOO_LARGE
|
The client tried to fetch a URI that was too long.
|
415
|
HTTP_UNSUPPORTED_MEDIA_TYPE
|
The client tried to PUT or POST data using an unsupported MIME type.
|
5XX Codes--Server-Side Errors |
500
|
HTTP_INTERNAL_SERVER_ERROR
(SERVER_ERROR)
|
The server encountered an unexpected error condition.
|
501
|
HTTP_NOT_IMPLEMENTED
(NOT_IMPLEMENTED)
|
An HTTP feature is unimplemented.
|
502
|
HTTP_BAD_GATEWAY
(BAD_GATEWAY)
|
An error occurred in a remote server during a proxy request.
|
503
|
HTTP_SERVICE_UNAVAILABLE
|
The server is temporarily down.
|
504
|
HTTP_GATEWAY_TIME_OUT
|
A remote server timed out during a proxy request.
|
505
|
HTTP_VERSION_NOT_SUPPORTED
|
The server doesn't support this version of HTTP.
|
506
|
HTTP_VARIANT_ALSO_VARIES
(VARIANT_ALSO_VARIES)
|
A negotiated document has several alternative representations.
|
The Perl examples throughout this book use the nicknames when available, even though their formal equivalents can be imported using the Apache::Constants
:http tag. We do this partly because of historical reasons and because the :common tag imports a small number of functions--only those we need for the majority of modules. As always with Perl, there's more than one way to do it; the choice is yours.
In addition to the HTTP status codes, Apache defines some return codes of its own which handlers use to send status information to the server.