Internet Engineering Task Force (IETF) R. Fielding, Ed.
Request for Comments: 7231 Adobe
Obsoletes: 2616 J. Reschke, Ed.
Updates: 2817 greenbytes
Category: Standards Track June 2014
Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content
The Hypertext Transfer Protocol (HTTP) is a stateless application-
level protocol for distributed, collaborative, hypertext information
systems. This document defines the semantics of HTTP/1.1 messages,
as expressed by request methods, request header fields, response
status codes, and response header fields, along with the payload of
messages (metadata and body content) and mechanisms for content
Status of This Memo
This is an Internet Standards Track document.
This document is a product of the Internet Engineering Task Force
(IETF). It represents the consensus of the IETF community. It has
received public review and has been approved for publication by the
Internet Engineering Steering Group (IESG). Further information on
Internet Standards is available in Section 2 of RFC 5741.
Information about the current status of this document, any errata,
and how to provide feedback on it may be obtained at
Copyright (c) 2014 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
This document may contain material from IETF Documents or IETF
Contributions published or made publicly available before November
10, 2008. The person(s) controlling the copyright in some of this
material may not have granted the IETF Trust the right to allow
modifications of such material outside the IETF Standards Process.
Without obtaining an adequate license from the person(s) controlling
the copyright in such materials, this document may not be modified
outside the IETF Standards Process, and derivative works of it may
not be created outside the IETF Standards Process, except to format
it for publication as an RFC or to translate it into languages other
7.1.4. Vary ...............................................707.2. Validator Header Fields ...................................717.3. Authentication Challenges .................................727.4. Response Context ..........................................727.4.1. Allow ..............................................727.4.2. Server .............................................738. IANA Considerations ............................................738.1. Method Registry ...........................................738.1.1. Procedure ..........................................748.1.2. Considerations for New Methods .....................748.1.3. Registrations ......................................758.2. Status Code Registry ......................................758.2.1. Procedure ..........................................758.2.2. Considerations for New Status Codes ................768.2.3. Registrations ......................................768.3. Header Field Registry .....................................778.3.1. Considerations for New Header Fields ...............788.3.2. Registrations ......................................808.4. Content Coding Registry ...................................818.4.1. Procedure ..........................................818.4.2. Registrations ......................................819. Security Considerations ........................................819.1. Attacks Based on File and Path Names ......................829.2. Attacks Based on Command, Code, or Query Injection ........829.3. Disclosure of Personal Information ........................839.4. Disclosure of Sensitive Information in URIs ...............839.5. Disclosure of Fragment after Redirects ....................849.6. Disclosure of Product Information .........................849.7. Browser Fingerprinting ....................................8410. Acknowledgments ...............................................8511. References ....................................................8511.1. Normative References .....................................8511.2. Informative References ...................................86Appendix A. Differences between HTTP and MIME .....................89A.1. MIME-Version ..............................................89A.2. Conversion to Canonical Form ..............................89A.3. Conversion of Date Formats ................................90A.4. Conversion of Content-Encoding ............................90A.5. Conversion of Content-Transfer-Encoding ...................90A.6. MHTML and Line Length Limitations .........................90Appendix B. Changes from RFC 2616 .................................91Appendix C. Imported ABNF .........................................93Appendix D. Collected ABNF ........................................94Index .............................................................97
Each Hypertext Transfer Protocol (HTTP) message is either a request
or a response. A server listens on a connection for a request,
parses each message received, interprets the message semantics in
relation to the identified request target, and responds to that
request with one or more response messages. A client constructs
request messages to communicate specific intentions, examines
received responses to see if the intentions were carried out, and
determines how to interpret the results. This document defines
HTTP/1.1 request and response semantics in terms of the architecture
defined in [RFC7230].
HTTP provides a uniform interface for interacting with a resource
(Section 2), regardless of its type, nature, or implementation, via
the manipulation and transfer of representations (Section 3).
HTTP semantics include the intentions defined by each request method
(Section 4), extensions to those semantics that might be described in
request header fields (Section 5), the meaning of status codes to
indicate a machine-readable response (Section 6), and the meaning of
other control data and resource metadata that might be given in
response header fields (Section 7).
This document also defines representation metadata that describe how
a payload is intended to be interpreted by a recipient, the request
header fields that might influence content selection, and the various
selection algorithms that are collectively referred to as "content
negotiation" (Section 3.4).
1.1. Conformance and Error Handling
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in [RFC2119].
Conformance criteria and considerations regarding error handling are
defined in Section 2.5 of [RFC7230].
1.2. Syntax Notation
This specification uses the Augmented Backus-Naur Form (ABNF)
notation of [RFC5234] with a list extension, defined in Section 7 of
[RFC7230], that allows for compact definition of comma-separated
lists using a '#' operator (similar to how the '*' operator indicates
repetition). Appendix C describes rules imported from other
documents. Appendix D shows the collected grammar with all list
operators expanded to standard ABNF notation.
This specification uses the terms "character", "character encoding
scheme", "charset", and "protocol element" as they are defined in
The target of an HTTP request is called a "resource". HTTP does not
limit the nature of a resource; it merely defines an interface that
might be used to interact with resources. Each resource is
identified by a Uniform Resource Identifier (URI), as described in
Section 2.7 of [RFC7230].
When a client constructs an HTTP/1.1 request message, it sends the
target URI in one of various forms, as defined in (Section 5.3 of
[RFC7230]). When a request is received, the server reconstructs an
effective request URI for the target resource (Section 5.5 of
One design goal of HTTP is to separate resource identification from
request semantics, which is made possible by vesting the request
semantics in the request method (Section 4) and a few
request-modifying header fields (Section 5). If there is a conflict
between the method semantics and any semantic implied by the URI
itself, as described in Section 4.2.1, the method semantics take
Considering that a resource could be anything, and that the uniform
interface provided by HTTP is similar to a window through which one
can observe and act upon such a thing only through the communication
of messages to some independent actor on the other side, an
abstraction is needed to represent ("take the place of") the current
or desired state of that thing in our communications. That
abstraction is called a representation [REST].
For the purposes of HTTP, a "representation" is information that is
intended to reflect a past, current, or desired state of a given
resource, in a format that can be readily communicated via the
protocol, and that consists of a set of representation metadata and a
potentially unbounded stream of representation data.
An origin server might be provided with, or be capable of generating,
multiple representations that are each intended to reflect the
current state of a target resource. In such cases, some algorithm is
used by the origin server to select one of those representations as
most applicable to a given request, usually based on content
negotiation. This "selected representation" is used to provide the
data and metadata for evaluating conditional requests [RFC7232] and
constructing the payload for 200 (OK) and 304 (Not Modified)
responses to GET (Section 4.3.1).
3.1. Representation Metadata
Representation header fields provide metadata about the
representation. When a message includes a payload body, the
representation header fields describe how to interpret the
representation data enclosed in the payload body. In a response to a
HEAD request, the representation header fields describe the
representation data that would have been enclosed in the payload body
if the same request had been a GET.
The following header fields convey representation metadata:
| Header Field Name | Defined in... |
| Content-Type | Section 22.214.171.124 |
| Content-Encoding | Section 126.96.36.199 |
| Content-Language | Section 188.8.131.52 |
| Content-Location | Section 184.108.40.206 |
3.1.1. Processing Representation Data
220.127.116.11. Media Type
HTTP uses Internet media types [RFC2046] in the Content-Type
(Section 18.104.22.168) and Accept (Section 5.3.2) header fields in order
to provide open and extensible data typing and type negotiation.
Media types define both a data format and various processing models:
how to process that data in accordance with each context in which it
media-type = type "/" subtype *( OWS ";" OWS parameter )
type = token
subtype = token
The type/subtype MAY be followed by parameters in the form of
parameter = token "=" ( token / quoted-string )
The type, subtype, and parameter name tokens are case-insensitive.
Parameter values might or might not be case-sensitive, depending on
the semantics of the parameter name. The presence or absence of a
parameter might be significant to the processing of a media-type,
depending on its definition within the media type registry.
A parameter value that matches the token production can be
transmitted either as a token or within a quoted-string. The quoted
and unquoted values are equivalent. For example, the following
examples are all equivalent, but the first is preferred for
Internet media types ought to be registered with IANA according to
the procedures defined in [BCP13].
Note: Unlike some similar constructs in other header fields, media
type parameters do not allow whitespace (even "bad" whitespace)
around the "=" character.
HTTP uses charset names to indicate or negotiate the character
encoding scheme of a textual representation [RFC6365]. A charset is
identified by a case-insensitive token.
charset = token
Charset names ought to be registered in the IANA "Character Sets"
registry (<http://www.iana.org/assignments/character-sets>) according
to the procedures defined in [RFC2978].
22.214.171.124. Canonicalization and Text Defaults
Internet media types are registered with a canonical form in order to
be interoperable among systems with varying native encoding formats.
Representations selected or transferred via HTTP ought to be in
canonical form, for many of the same reasons described by the
Multipurpose Internet Mail Extensions (MIME) [RFC2045]. However, the
performance characteristics of email deployments (i.e., store and
forward messages to peers) are significantly different from those
common to HTTP and the Web (server-based information services).
Furthermore, MIME's constraints for the sake of compatibility with
older mail transfer protocols do not apply to HTTP (see Appendix A).
MIME's canonical form requires that media subtypes of the "text" type
use CRLF as the text line break. HTTP allows the transfer of text
media with plain CR or LF alone representing a line break, when such
line breaks are consistent for an entire representation. An HTTP
sender MAY generate, and a recipient MUST be able to parse, line
breaks in text media that consist of CRLF, bare CR, or bare LF. In
addition, text media in HTTP is not limited to charsets that use
octets 13 and 10 for CR and LF, respectively. This flexibility
regarding line breaks applies only to text within a representation
that has been assigned a "text" media type; it does not apply to
"multipart" types or HTTP elements outside the payload body (e.g.,
If a representation is encoded with a content-coding, the underlying
data ought to be in a form defined above prior to being encoded.
126.96.36.199. Multipart Types
MIME provides for a number of "multipart" types -- encapsulations of
one or more representations within a single message body. All
multipart types share a common syntax, as defined in Section 5.1.1 of
[RFC2046], and include a boundary parameter as part of the media type
value. The message body is itself a protocol element; a sender MUST
generate only CRLF to represent line breaks between body parts.
HTTP message framing does not use the multipart boundary as an
indicator of message body length, though it might be used by
implementations that generate or process the payload. For example,
the "multipart/form-data" type is often used for carrying form data
in a request, as described in [RFC2388], and the "multipart/
byteranges" type is defined by this specification for use in some 206
(Partial Content) responses [RFC7233].
The "Content-Type" header field indicates the media type of the
associated representation: either the representation enclosed in the
message payload or the selected representation, as determined by the
message semantics. The indicated media type defines both the data
format and how that data is intended to be processed by a recipient,
within the scope of the received message semantics, after any content
codings indicated by Content-Encoding are decoded.
Content-Type = media-type
Media types are defined in Section 188.8.131.52. An example of the field
Content-Type: text/html; charset=ISO-8859-4
A sender that generates a message containing a payload body SHOULD
generate a Content-Type header field in that message unless the
intended media type of the enclosed representation is unknown to the
sender. If a Content-Type header field is not present, the recipient
MAY either assume a media type of "application/octet-stream"
([RFC2046], Section 4.5.1) or examine the data to determine its type.
In practice, resource owners do not always properly configure their
origin server to provide the correct Content-Type for a given
representation, with the result that some clients will examine a
payload's content and override the specified type. Clients that do
so risk drawing incorrect conclusions, which might expose additional
security risks (e.g., "privilege escalation"). Furthermore, it is
impossible to determine the sender's intent by examining the data
format: many data formats match multiple media types that differ only
in processing semantics. Implementers are encouraged to provide a
means of disabling such "content sniffing" when it is used.
3.1.2. Encoding for Compression or Integrity
184.108.40.206. Content Codings
Content coding values indicate an encoding transformation that has
been or can be applied to a representation. Content codings are
primarily used to allow a representation to be compressed or
otherwise usefully transformed without losing the identity of its
underlying media type and without loss of information. Frequently,
the representation is stored in coded form, transmitted directly, and
only decoded by the final recipient.
content-coding = token
All content-coding values are case-insensitive and ought to be
registered within the "HTTP Content Coding Registry", as defined in
Section 8.4. They are used in the Accept-Encoding (Section 5.3.4)
and Content-Encoding (Section 220.127.116.11) header fields.
The following content-coding values are defined by this
compress (and x-compress): See Section 4.2.1 of [RFC7230].
deflate: See Section 4.2.2 of [RFC7230].
gzip (and x-gzip): See Section 4.2.3 of [RFC7230].
The "Content-Encoding" header field indicates what content codings
have been applied to the representation, beyond those inherent in the
media type, and thus what decoding mechanisms have to be applied in
order to obtain data in the media type referenced by the Content-Type
header field. Content-Encoding is primarily used to allow a
representation's data to be compressed without losing the identity of
its underlying media type.
Content-Encoding = 1#content-coding
An example of its use is
If one or more encodings have been applied to a representation, the
sender that applied the encodings MUST generate a Content-Encoding
header field that lists the content codings in the order in which
they were applied. Additional information about the encoding
parameters can be provided by other header fields not defined by this
Unlike Transfer-Encoding (Section 3.3.1 of [RFC7230]), the codings
listed in Content-Encoding are a characteristic of the
representation; the representation is defined in terms of the coded
form, and all other metadata about the representation is about the
coded form unless otherwise noted in the metadata definition.
Typically, the representation is only decoded just prior to rendering
or analogous usage.
If the media type includes an inherent encoding, such as a data
format that is always compressed, then that encoding would not be
restated in Content-Encoding even if it happens to be the same
algorithm as one of the content codings. Such a content coding would
only be listed if, for some bizarre reason, it is applied a second
time to form the representation. Likewise, an origin server might
choose to publish the same data as multiple representations that
differ only in whether the coding is defined as part of Content-Type
or Content-Encoding, since some user agents will behave differently
in their handling of each response (e.g., open a "Save as ..." dialog
instead of automatic decompression and rendering of content).
An origin server MAY respond with a status code of 415 (Unsupported
Media Type) if a representation in the request message has a content
coding that is not acceptable.
3.1.3. Audience Language
18.104.22.168. Language Tags
A language tag, as defined in [RFC5646], identifies a natural
language spoken, written, or otherwise conveyed by human beings for
communication of information to other human beings. Computer
languages are explicitly excluded.
HTTP uses language tags within the Accept-Language and
Content-Language header fields. Accept-Language uses the broader
language-range production defined in Section 5.3.5, whereas
Content-Language uses the language-tag production defined below.
language-tag = <Language-Tag, see [RFC5646], Section 2.1>
A language tag is a sequence of one or more case-insensitive subtags,
each separated by a hyphen character ("-", %x2D). In most cases, a
language tag consists of a primary language subtag that identifies a
broad family of related languages (e.g., "en" = English), which is
optionally followed by a series of subtags that refine or narrow that
language's range (e.g., "en-CA" = the variety of English as
communicated in Canada). Whitespace is not allowed within a language
tag. Example tags include:
fr, en-US, es-419, az-Arab, x-pig-latin, man-Nkoo-GN
See [RFC5646] for further information.
The "Content-Language" header field describes the natural language(s)
of the intended audience for the representation. Note that this
might not be equivalent to all the languages used within the
Content-Language = 1#language-tag
Language tags are defined in Section 22.214.171.124. The primary purpose of
Content-Language is to allow a user to identify and differentiate
representations according to the users' own preferred language.
Thus, if the content is intended only for a Danish-literate audience,
the appropriate field is
If no Content-Language is specified, the default is that the content
is intended for all language audiences. This might mean that the
sender does not consider it to be specific to any natural language,
or that the sender does not know for which language it is intended.
Multiple languages MAY be listed for content that is intended for
multiple audiences. For example, a rendition of the "Treaty of
Waitangi", presented simultaneously in the original Maori and English
versions, would call for
Content-Language: mi, en
However, just because multiple languages are present within a
representation does not mean that it is intended for multiple
linguistic audiences. An example would be a beginner's language
primer, such as "A First Lesson in Latin", which is clearly intended
to be used by an English-literate audience. In this case, the
Content-Language would properly only include "en".
Content-Language MAY be applied to any media type -- it is not
limited to textual documents.
126.96.36.199. Identifying a Representation
When a complete or partial representation is transferred in a message
payload, it is often desirable for the sender to supply, or the
recipient to determine, an identifier for a resource corresponding to
For a request message:
o If the request has a Content-Location header field, then the
sender asserts that the payload is a representation of the
resource identified by the Content-Location field-value. However,
such an assertion cannot be trusted unless it can be verified by
other means (not defined by this specification). The information
might still be useful for revision history links.
o Otherwise, the payload is unidentified.
For a response message, the following rules are applied in order
until a match is found:
1. If the request method is GET or HEAD and the response status code
is 200 (OK), 204 (No Content), 206 (Partial Content), or 304 (Not
Modified), the payload is a representation of the resource
identified by the effective request URI (Section 5.5 of
2. If the request method is GET or HEAD and the response status code
is 203 (Non-Authoritative Information), the payload is a
potentially modified or enhanced representation of the target
resource as provided by an intermediary.
3. If the response has a Content-Location header field and its
field-value is a reference to the same URI as the effective
request URI, the payload is a representation of the resource
identified by the effective request URI.
4. If the response has a Content-Location header field and its
field-value is a reference to a URI different from the effective
request URI, then the sender asserts that the payload is a
representation of the resource identified by the Content-Location
field-value. However, such an assertion cannot be trusted unless
it can be verified by other means (not defined by this
5. Otherwise, the payload is unidentified.
The "Content-Location" header field references a URI that can be used
as an identifier for a specific resource corresponding to the
representation in this message's payload. In other words, if one
were to perform a GET request on this URI at the time of this
message's generation, then a 200 (OK) response would contain the same
representation that is enclosed as payload in this message.
Content-Location = absolute-URI / partial-URI
The Content-Location value is not a replacement for the effective
Request URI (Section 5.5 of [RFC7230]). It is representation
metadata. It has the same syntax and semantics as the header field
of the same name defined for MIME body parts in Section 4 of
[RFC2557]. However, its appearance in an HTTP message has some
special implications for HTTP recipients.
If Content-Location is included in a 2xx (Successful) response
message and its value refers (after conversion to absolute form) to a
URI that is the same as the effective request URI, then the recipient
MAY consider the payload to be a current representation of that
resource at the time indicated by the message origination date. For
a GET (Section 4.3.1) or HEAD (Section 4.3.2) request, this is the
same as the default semantics when no Content-Location is provided by
the server. For a state-changing request like PUT (Section 4.3.4) or
POST (Section 4.3.3), it implies that the server's response contains
the new representation of that resource, thereby distinguishing it
from representations that might only report about the action (e.g.,
"It worked!"). This allows authoring applications to update their
local copies without the need for a subsequent GET request.
If Content-Location is included in a 2xx (Successful) response
message and its field-value refers to a URI that differs from the
effective request URI, then the origin server claims that the URI is
an identifier for a different resource corresponding to the enclosed
representation. Such a claim can only be trusted if both identifiers
share the same resource owner, which cannot be programmatically
determined via HTTP.
o For a response to a GET or HEAD request, this is an indication
that the effective request URI refers to a resource that is
subject to content negotiation and the Content-Location
field-value is a more specific identifier for the selected
o For a 201 (Created) response to a state-changing method, a
Content-Location field-value that is identical to the Location
field-value indicates that this payload is a current
representation of the newly created resource.
o Otherwise, such a Content-Location indicates that this payload is
a representation reporting on the requested action's status and
that the same report is available (for future access with GET) at
the given URI. For example, a purchase transaction made via a
POST request might include a receipt document as the payload of
the 200 (OK) response; the Content-Location field-value provides
an identifier for retrieving a copy of that same receipt in the
A user agent that sends Content-Location in a request message is
stating that its value refers to where the user agent originally
obtained the content of the enclosed representation (prior to any
modifications made by that user agent). In other words, the user
agent is providing a back link to the source of the original
An origin server that receives a Content-Location field in a request
message MUST treat the information as transitory request context
rather than as metadata to be saved verbatim as part of the
representation. An origin server MAY use that context to guide in
processing the request or to save it for other uses, such as within
source links or versioning metadata. However, an origin server MUST
NOT use such context information to alter the request semantics.
For example, if a client makes a PUT request on a negotiated resource
and the origin server accepts that PUT (without redirection), then
the new state of that resource is expected to be consistent with the
one representation supplied in that PUT; the Content-Location cannot
be used as a form of reverse content selection identifier to update
only one of the negotiated representations. If the user agent had
wanted the latter semantics, it would have applied the PUT directly
to the Content-Location URI.
3.2. Representation Data
The representation data associated with an HTTP message is either
provided as the payload body of the message or referred to by the
message semantics and the effective request URI. The representation
data is in a format and encoding defined by the representation
metadata header fields.
The data type of the representation data is determined via the header
fields Content-Type and Content-Encoding. These define a two-layer,
ordered encoding model:
representation-data := Content-Encoding( Content-Type( bits ) )
3.3. Payload Semantics
Some HTTP messages transfer a complete or partial representation as
the message "payload". In some cases, a payload might contain only
the associated representation's header fields (e.g., responses to
HEAD) or only some part(s) of the representation data (e.g., the 206
(Partial Content) status code).
The purpose of a payload in a request is defined by the method
semantics. For example, a representation in the payload of a PUT
request (Section 4.3.4) represents the desired state of the target
resource if the request is successfully applied, whereas a
representation in the payload of a POST request (Section 4.3.3)
represents information to be processed by the target resource.
In a response, the payload's purpose is defined by both the request
method and the response status code. For example, the payload of a
200 (OK) response to GET (Section 4.3.1) represents the current state
of the target resource, as observed at the time of the message
origination date (Section 188.8.131.52), whereas the payload of the same
status code in a response to POST might represent either the
processing result or the new state of the target resource after
applying the processing. Response messages with an error status code
usually contain a payload that represents the error condition, such
that it describes the error state and what next steps are suggested
for resolving it.
Header fields that specifically describe the payload, rather than the
associated representation, are referred to as "payload header
fields". Payload header fields are defined in other parts of this
specification, due to their impact on message parsing.
| Header Field Name | Defined in... |
| Content-Length | Section 3.3.2 of [RFC7230] |
| Content-Range | Section 4.2 of [RFC7233] |
| Trailer | Section 4.4 of [RFC7230] |
| Transfer-Encoding | Section 3.3.1 of [RFC7230] |
3.4. Content Negotiation
When responses convey payload information, whether indicating a
success or an error, the origin server often has different ways of
representing that information; for example, in different formats,
languages, or encodings. Likewise, different users or user agents
might have differing capabilities, characteristics, or preferences
that could influence which representation, among those available,
would be best to deliver. For this reason, HTTP provides mechanisms
for content negotiation.
This specification defines two patterns of content negotiation that
can be made visible within the protocol: "proactive", where the
server selects the representation based upon the user agent's stated
preferences, and "reactive" negotiation, where the server provides a
list of representations for the user agent to choose from. Other
patterns of content negotiation include "conditional content", where
the representation consists of multiple parts that are selectively
rendered based on user agent parameters, "active content", where the
representation contains a script that makes additional (more
specific) requests based on the user agent characteristics, and
"Transparent Content Negotiation" ([RFC2295]), where content
selection is performed by an intermediary. These patterns are not
mutually exclusive, and each has trade-offs in applicability and
Note that, in all cases, HTTP is not aware of the resource semantics.
The consistency with which an origin server responds to requests,
over time and over the varying dimensions of content negotiation, and
thus the "sameness" of a resource's observed representations over
time, is determined entirely by whatever entity or algorithm selects
or generates those responses. HTTP pays no attention to the man
behind the curtain.
3.4.1. Proactive Negotiation
When content negotiation preferences are sent by the user agent in a
request to encourage an algorithm located at the server to select the
preferred representation, it is called proactive negotiation (a.k.a.,
server-driven negotiation). Selection is based on the available
representations for a response (the dimensions over which it might
vary, such as language, content-coding, etc.) compared to various
information supplied in the request, including both the explicit
negotiation fields of Section 5.3 and implicit characteristics, such
as the client's network address or parts of the User-Agent field.
Proactive negotiation is advantageous when the algorithm for
selecting from among the available representations is difficult to
describe to a user agent, or when the server desires to send its
"best guess" to the user agent along with the first response (hoping
to avoid the round trip delay of a subsequent request if the "best
guess" is good enough for the user). In order to improve the
server's guess, a user agent MAY send request header fields that
describe its preferences.
Proactive negotiation has serious disadvantages:
o It is impossible for the server to accurately determine what might
be "best" for any given user, since that would require complete
knowledge of both the capabilities of the user agent and the
intended use for the response (e.g., does the user want to view it
on screen or print it on paper?);
o Having the user agent describe its capabilities in every request
can be both very inefficient (given that only a small percentage
of responses have multiple representations) and a potential risk
to the user's privacy;
o It complicates the implementation of an origin server and the
algorithms for generating responses to a request; and,
o It limits the reusability of responses for shared caching.
A user agent cannot rely on proactive negotiation preferences being
consistently honored, since the origin server might not implement
proactive negotiation for the requested resource or might decide that
sending a response that doesn't conform to the user agent's
preferences is better than sending a 406 (Not Acceptable) response.
A Vary header field (Section 7.1.4) is often sent in a response
subject to proactive negotiation to indicate what parts of the
request information were used in the selection algorithm.
3.4.2. Reactive Negotiation
With reactive negotiation (a.k.a., agent-driven negotiation),
selection of the best response representation (regardless of the
status code) is performed by the user agent after receiving an
initial response from the origin server that contains a list of
resources for alternative representations. If the user agent is not
satisfied by the initial response representation, it can perform a
GET request on one or more of the alternative resources, selected
based on metadata included in the list, to obtain a different form of
representation for that response. Selection of alternatives might be
performed automatically by the user agent or manually by the user
selecting from a generated (possibly hypertext) menu.
Note that the above refers to representations of the response, in
general, not representations of the resource. The alternative
representations are only considered representations of the target
resource if the response in which those alternatives are provided has
the semantics of being a representation of the target resource (e.g.,
a 200 (OK) response to a GET request) or has the semantics of
providing links to alternative representations for the target
resource (e.g., a 300 (Multiple Choices) response to a GET request).
A server might choose not to send an initial representation, other
than the list of alternatives, and thereby indicate that reactive
negotiation by the user agent is preferred. For example, the
alternatives listed in responses with the 300 (Multiple Choices) and
406 (Not Acceptable) status codes include information about the
available representations so that the user or user agent can react by
making a selection.
Reactive negotiation is advantageous when the response would vary
over commonly used dimensions (such as type, language, or encoding),
when the origin server is unable to determine a user agent's
capabilities from examining the request, and generally when public
caches are used to distribute server load and reduce network usage.
Reactive negotiation suffers from the disadvantages of transmitting a
list of alternatives to the user agent, which degrades user-perceived
latency if transmitted in the header section, and needing a second
request to obtain an alternate representation. Furthermore, this
specification does not define a mechanism for supporting automatic
selection, though it does not prevent such a mechanism from being
developed as an extension.