Apache HTTP Headers and Codes
Apache HTTP Headers and Codes
HTTP Headers
and Status Codes
THIS APPENDIX DOCUMENTS HTTP status codes and headers.
Status Codes
The HTTP server reply status line contains three fields: HTTP version, status code, and
description in the following format. Status is given with a three-digit server response
code. Status codes are grouped as shown in Table H-1.
1XX: Informational
This class of status code consists only of the status line and optional headers, termi-
nated by an empty line. HTTP/1.0 hasn’t defined any 1XX status codes; these are
reserved for future use.
100 Continue
The client should continue with its request. This is an interim response used to inform
the client that the initial part of the request has been received and hasn’t yet been
rejected by the server. The client should send the rest of the request or ignore this
response if the request has already completed. The server sends a final response when
the request is fully completed.
1
Appendix H
2XX: Success
These status codes indicate that the client’s request was successfully received, under-
stood, and accepted.
200 OK
The request has succeeded. The server’s response contains the requested data.
201 Created
The request has been carried out, and a new resource has been created. The URI(s)
returned in the entity of the response can be used to reference the newly created
resource.
202 Accepted
The request has been accepted but not yet fully processed. The request may or may not
eventually be acted upon because it might be disallowed when the processing actually
takes place.
204 No Content
The server has carried out the request but doesn’t need to return an entity body.
Browsers shouldn’t update their document view upon receiving this response. This is
useful code for an image-map handler to return when the user clicks the useless or
blank areas of the image.
2
HTTP Headers and Status Code
3XX: Redirection
These codes indicate that the user agent needs to take further actions for the request to
be successfully carried out.
302 Found
The requested resource resides temporarily under a different URI. The Location header
points to the new location. The client should use the new URI to resolve the request,
but the old URI should be used for future requests because the redirection may not be
permanent.
3
Appendix H
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 authentica-
tion when requesting the same URI again.
403 Forbidden
The server understood the request but is refusing to fulfill it. The request shouldn’t be
repeated.
4
HTTP Headers and Status Code
409 Conflict
The request couldn’t be completed because of a conflict with the current state of the
resource.
410 Gone
The requested resource is no longer available at the server, and no forwarding address
is known.
5
Appendix H
HTTP Headers
HTTP headers transfer information between the client and server. There are four cate-
gories of headers, as shown in Table H-2.
General and Entity headers are same for both client and servers. All headers follow the
Name: value format. Header names are case-insensitive. In HTTP/1.1, the value of
headers can extend over multiple lines by preceding each extra line with at least one
space or tab. All headers are terminated by a carriage-return newline sequence (\r\n).
General Headers
These header fields have general applicability for both request and response messages
but don’t apply to the entity being transferred. These header fields apply only to the
message being transmitted.
6
HTTP Headers and Status Code
Cache-Control: Directives
Caching directives are specified in a comma-separated list. They fall into two cate-
gories—request-based and response-based. Table H-3 describes the allowed request
directives, and Table H-4 describes the allowed response directives.
Connection: options
The header allows the sender to specify options that are to be used for a particular
connection and must not be communicated by proxies over further connections.
HTTP/1.1 defines the close connection option to allow the sender to signal that the
connection will be closed after the response has been completed.
7
Appendix H
Date: date-in-rfc1123-format
Represents the date and time at which the message was originated. The field value is
sent in RFC 1123 date format. An example is as follows:
Pragma: no-cache
When a request message contains the Pragma: no-cache directive, an application
should forward the request to the origin server even if it has a cached copy of what’s
being requested.
Trailer: header-fields
This header indicates that the given set of header fields is present in the trailer of a
message encoded with chunked transfer encoding.
Transfer-Encoding: encoding-type
Transfer encoding values indicate an encoding transformation that has been, can be,
or may need to be applied to an entity body in ensure “safe transport” through the
network.
Upgrade: protocol/version
This header allows the client to specify to the server what additional communication
protocols it supports and would like to use. If the server finds it appropriate to switch
protocols, it’ll use this header within a 101 (Switching Protocols) response.
Request Headers
These header fields allow the client to pass additional information about the request,
and about the client itself, to the server.
8
HTTP Headers and Status Code
Authorization: credentials
This provides the client’s authorization to access the URI. When a requested URI
requires authorization, the server responds with a WWW-Authenticate header describing
the type of authorization required. The client then repeats the request with proper
authorization information.
From: email
This header contains an Internet e-mail address for the human controlling the request-
ing user agent.
If-Match:
A client that has previously obtained one or more entities from the resource can
include a list of their associated entity tags in this header field to verify that one of
those entities is current.
9
Appendix H
If-Modified-Since: datein-rfc1123-format
This header specifies that the URI data should be sent only if it has been modified
since the date given.
If-None-Match: entity-tags
This header is similar to the If-Match header but is used to verify that none of those
entities previously obtained by the client is current.
If-Unmodified-Since: date-in-rfc1123-format
This specifies that the URI data should only be sent if it hasn’t been modified since the
given date.
Max-Forwards: number
This header limits the number of proxies and gateways that can forward the request.
Proxy-Authorization: credentials
The Proxy-Authentication request header allows the client to identify itself (or its user)
to a proxy that requires authentication.
Range: bytes=n-m
Using this header with a conditional or unconditional GET allows the retrieval of one or
more subranges of an entity, rather than the entire entity.
Referer: url
The Referer request header allows the client to specify the URI of the resource from
which the requested URL was obtained.
10
HTTP Headers and Status Code
Response Headers
Response headers carry additional meta information about the response that can’t be
placed in the status line. These headers give information about the server and about
further access to the resource identified by the requested URI.
Age: seconds
This header contains the sender’s estimate of the amount of time since the response
was generated at the origin server.
Etag: entity-tag
This header provides the current value of the requested entity tag. See the FileETag
directive for details.
Location: URI
This is used to redirect the recipient to a location other than the Request-URI to com-
plete the request.
11
Appendix H
Server string
The Server header contains information about the software that the origin server used
to handle the request.
Vary: * | headers
This header specifies that the entity has multiple sources and may therefore vary
according to a specified list of request headers. Multiple headers can be listed sepa-
rated by commas. An asterisk means another factor other than the request headers
may affect the response that is returned.
Entity Headers
Entity headers, also called content headers, define meta information about the body of
an HTTP request or response (the entity body) or about the resource identified by a
request.
Allow: methods
This header informs the recipient of valid methods associated with the resource.
Content-Encoding: encoding
This header indicates what additional content codings have been applied to the entity
body and hence what decoding must be carried out to obtain the media-type refer-
enced by the Content-Type header.
Content-Language: languages
The Content-Language header describes the natural language(s) of the intended audi-
ence for the enclosed entity.
Content-Length: n
This header indicates the size of the entity body. Because of the dynamic nature of
some requests, the content length is sometimes unknown, and this header is omitted
(for example, with chunked transfer encoding).
The Content-Language header supplies the resource location for the entity
enclosed in the message when that entity may be accessed from a different location to
the requested resource’s URI.
12
HTTP Headers and Status Code
Content-MD5: digest
This header contains an MD5 digest of the entity body that’s used to provide an
end-to-end Message Integrity Check (MIC) of the entity body, as implemented by
mod_auth_digest. See RFC 1864 for more details.
Content-Type: type/subtype
This header describes the media type of the entity body sent to the recipient. In the
case of the HEAD method, it describes the media type that would have been sent had the
request been a GET.
Expires: RFC-1123-date
The Expires header gives the date and time after which the response is considered
stale.
Last-Modified: RFC-1123-date
This header indicates the date and time at which the origin server believes the variant
was last modified.
13