• network working group r. fielding
    request for comments: 2616 uc irvine
    obsoletes: 2068 j. gettys
    category: standards track compaq/w3c
    j. mogul
    compaq
    h. frystyk
    w3c/mit
    l. masinter
    xerox
    p. leach
    microsoft
    t. berners-lee
    w3c/mit
    june 1999

    hypertext transfer protocol -- http/1.1

    status of this memo

    this document specifies an internet standards track protocol for the
    internet community, and requests discussion and suggestions for
    improvements. please refer to the current edition of the "internet
    official protocol standards" (std 1) for the standardization state
    and status of this protocol. distribution of this memo is unlimited.

    copyright notice

    copyright (c) the internet society (1999). all rights reserved.

    abstract

    the hypertext transfer protocol (http) is an application-level
    protocol for distributed, collaborative, hypermedia information
    systems. it is a generic, stateless, protocol which can be used for
    many tasks beyond its use for hypertext, such as name servers and
    distributed object management systems, through extension of its
    request methods, error codes and headers [47]. a feature of http is
    the typing and negotiation of data representation, allowing systems
    to be built independently of the data being transferred.

    http has been in use by the world-wide web global information
    initiative since 1990. this specification defines the protocol
    referred to as "http/1.1", and is an update to rfc 2068 [33].

    fielding, et al. standards track [page 1]

    rfc 2616 http/1.1 june 1999

    table of contents

    1 introduction ...................................................7
    1.1 purpose......................................................7
    1.2 requirements .................................................8
    1.3 terminology ..................................................8
    1.4 overall operation ...........................................12
    2 notational conventions and generic grammar ....................14
    2.1 augmented bnf ...............................................14
    2.2 basic rules .................................................15
    3 protocol parameters ...........................................17
    3.1 http version ................................................17
    3.2 uniform resource identifiers ................................18
    3.2.1 general syntax ...........................................19
    3.2.2 http url .................................................19
    3.2.3 uri comparison ...........................................20
    3.3 date/time formats ...........................................20
    3.3.1 full date ................................................20
    3.3.2 delta seconds ............................................21
    3.4 character sets ..............................................21
    3.4.1 missing charset ..........................................22
    3.5 content codings .............................................23
    3.6 transfer codings ............................................24
    3.6.1 chunked transfer coding ..................................25
    3.7 media types .................................................26
    3.7.1 canonicalization and text defaults .......................27
    3.7.2 multipart types ..........................................27
    3.8 product tokens ..............................................28
    3.9 quality values ..............................................29
    3.10 language tags ...............................................29
    3.11 entity tags .................................................30
    3.12 range units .................................................30
    4 http message ..................................................31
    4.1 message types ...............................................31
    4.2 message headers .............................................31
    4.3 message body ................................................32
    4.4 message length ..............................................33
    4.5 general header fields .......................................34
    5 request .......................................................35
    5.1 request-line ................................................35
    5.1.1 method ...................................................36
    5.1.2 request-uri ..............................................36
    5.2 the resource identified by a request ........................38
    5.3 request header fields .......................................38
    6 response ......................................................39
    6.1 status-line .................................................39
    6.1.1 status code and reason phrase ............................39
    6.2 response header fields ......................................41

    fielding, et al. standards track [page 2]

    rfc 2616 http/1.1 june 1999

    7 entity ........................................................42
    7.1 entity header fields ........................................42
    7.2 entity body .................................................43
    7.2.1 type .....................................................43
    7.2.2 entity length ............................................43
    8 connections ...................................................44
    8.1 persistent connections ......................................44
    8.1.1 purpose ..................................................44
    8.1.2 overall operation ........................................45
    8.1.3 proxy servers ............................................46
    8.1.4 practical considerations .................................46
    8.2 message transmission requirements ...........................47
    8.2.1 persistent connections and flow control ..................47
    8.2.2 monitoring connections for error status messages .........48
    8.2.3 use of the 100 (continue) status .........................48
    8.2.4 client behavior if server prematurely closes connection ..50
    9 method definitions ............................................51
    9.1 safe and idempotent methods .................................51
    9.1.1 safe methods .............................................51
    9.1.2 idempotent methods .......................................51
    9.2 options .....................................................52
    9.3 get .........................................................53
    9.4 head ........................................................54
    9.5 post ........................................................54
    9.6 put .........................................................55
    9.7 delete ......................................................56
    9.8 trace .......................................................56
    9.9 connect .....................................................57
    10 status code definitions ......................................57
    10.1 informational 1xx ...........................................57
    10.1.1 100 continue .............................................58
    10.1.2 101 switching protocols ..................................58
    10.2 successful 2xx ..............................................58
    10.2.1 200 ok ...................................................58
    10.2.2 201 created ..............................................59
    10.2.3 202 accepted .............................................59
    10.2.4 203 non-authoritative information ........................59
    10.2.5 204 no content ...........................................60
    10.2.6 205 reset content ........................................60
    10.2.7 206 partial content ......................................60
    10.3 redirection 3xx .............................................61
    10.3.1 300 multiple choices .....................................61
    10.3.2 301 moved permanently ....................................62
    10.3.3 302 found ................................................62
    10.3.4 303 see other ............................................63
    10.3.5 304 not modified .........................................63
    10.3.6 305 use proxy ............................................64
    10.3.7 306 (unused) .............................................64

    fielding, et al. standards track [page 3]

    rfc 2616 http/1.1 june 1999

    10.3.8 307 temporary redirect ...................................65
    10.4 client error 4xx ............................................65
    10.4.1 400 bad request .........................................65
    10.4.2 401 unauthorized ........................................66
    10.4.3 402 payment required ....................................66
    10.4.4 403 forbidden ...........................................66
    10.4.5 404 not found ...........................................66
    10.4.6 405 method not allowed ..................................66
    10.4.7 406 not acceptable ......................................67
    10.4.8 407 proxy authentication required .......................67
    10.4.9 408 request timeout .....................................67
    10.4.10 409 conflict ............................................67
    10.4.11 410 gone ................................................68
    10.4.12 411 length required .....................................68
    10.4.13 412 precondition failed .................................68
    10.4.14 413 request entity too large ............................69
    10.4.15 414 request-uri too long ................................69
    10.4.16 415 unsupported media type ..............................69
    10.4.17 416 requested range not satisfiable .....................69
    10.4.18 417 expectation failed ..................................70
    10.5 server error 5xx ............................................70
    10.5.1 500 internal server error ................................70
    10.5.2 501 not implemented ......................................70
    10.5.3 502 bad gateway ..........................................70
    10.5.4 503 service unavailable ..................................70
    10.5.5 504 gateway timeout ......................................71
    10.5.6 505 http version not supported ...........................71
    11 access authentication ........................................71
    12 content negotiation ..........................................71
    12.1 server-driven negotiation ...................................72
    12.2 agent-driven negotiation ....................................73
    12.3 transparent negotiation .....................................74
    13 caching in http ..............................................74
    13.1.1 cache correctness ........................................75
    13.1.2 warnings .................................................76
    13.1.3 cache-control mechanisms .................................77
    13.1.4 explicit user agent warnings .............................78
    13.1.5 exceptions to the rules and warnings .....................78
    13.1.6 client-controlled behavior ...............................79
    13.2 expiration model ............................................79
    13.2.1 server-specified expiration ..............................79
    13.2.2 heuristic expiration .....................................80
    13.2.3 age calculations .........................................80
    13.2.4 expiration calculations ..................................83
    13.2.5 disambiguating expiration values .........................84
    13.2.6 disambiguating multiple responses ........................84
    13.3 validation model ............................................85
    13.3.1 last-modified dates ......................................86

    fielding, et al. standards track [page 4]

    rfc 2616 http/1.1 june 1999

    13.3.2 entity tag cache validators ..............................86
    13.3.3 weak and strong validators ...............................86
    13.3.4 rules for when to use entity tags and last-modified dates.89
    13.3.5 non-validating conditionals ..............................90
    13.4 response cacheability .......................................91
    13.5 constructing responses from caches ..........................92
    13.5.1 end-to-end and hop-by-hop headers ........................92
    13.5.2 non-modifiable headers ...................................92
    13.5.3 combining headers ........................................94
    13.5.4 combining byte ranges ....................................95
    13.6 caching negotiated responses ................................95
    13.7 shared and non-shared caches ................................96
    13.8 errors or incomplete response cache behavior ................97
    13.9 side effects of get and head ................................97
    13.10 invalidation after updates or deletions ...................97
    13.11 write-through mandatory ...................................98
    13.12 cache replacement .........................................99
    13.13 history lists .............................................99
    14 header field definitions ....................................100
    14.1 accept .....................................................100
    14.2 accept-charset .............................................102
    14.3 accept-encoding ............................................102
    14.4 accept-language ............................................104
    14.5 accept-ranges ..............................................105
    14.6 age ........................................................106
    14.7 allow ......................................................106
    14.8 authorization ..............................................107
    14.9 cache-control ..............................................108
    14.9.1 what is cacheable .......................................109
    14.9.2 what may be stored by caches ............................110
    14.9.3 modifications of the basic expiration mechanism .........111
    14.9.4 cache revalidation and reload controls ..................113
    14.9.5 no-transform directive ..................................115
    14.9.6 cache control extensions ................................116
    14.10 connection ...............................................117
    14.11 content-encoding .........................................118
    14.12 content-language .........................................118
    14.13 content-length ...........................................119
    14.14 content-location .........................................120
    14.15 content-md5 ..............................................121
    14.16 content-range ............................................122
    14.17 content-type .............................................124
    14.18 date .....................................................124
    14.18.1 clockless origin server operation ......................125
    14.19 etag .....................................................126
    14.20 expect ...................................................126
    14.21 expires ..................................................127
    14.22 from .....................................................128

    fielding, et al. standards track [page 5]

    rfc 2616 http/1.1 june 1999

    14.23 host .....................................................128
    14.24 if-match .................................................129
    14.25 if-modified-since ........................................130
    14.26 if-none-match ............................................132
    14.27 if-range .................................................133
    14.28 if-unmodified-since ......................................134
    14.29 last-modified ............................................134
    14.30 location .................................................135
    14.31 max-forwards .............................................136
    14.32 pragma ...................................................136
    14.33 proxy-authenticate .......................................137
    14.34 proxy-authorization ......................................137
    14.35 range ....................................................138
    14.35.1 byte ranges ...........................................138
    14.35.2 range retrieval requests ..............................139
    14.36 referer ..................................................140
    14.37 retry-after ..............................................141
    14.38 server ...................................................141
    14.39 te .......................................................142
    14.40 trailer ..................................................143
    14.41 transfer-encoding..........................................143
    14.42 upgrade ..................................................144
    14.43 user-agent ...............................................145
    14.44 vary .....................................................145
    14.45 via ......................................................146
    14.46 warning ..................................................148
    14.47 www-authenticate .........................................150
    15 security considerations .......................................150
    15.1 personal information....................................151
    15.1.1 abuse of server log information .........................151
    15.1.2 transfer of sensitive information .......................151
    15.1.3 encoding sensitive information in uri's .................152
    15.1.4 privacy issues connected to accept headers ..............152
    15.2 attacks based on file and path names .......................153
    15.3 dns spoofing ...............................................154
    15.4 location headers and spoofing ..............................154
    15.5 content-disposition issues .................................154
    15.6 authentication credentials and idle clients ................155
    15.7 proxies and caching ........................................155
    15.7.1 denial of service attacks on proxies....................156
    16 acknowledgments .............................................156
    17 references ..................................................158
    18 authors' addresses ..........................................162
    19 appendices ..................................................164
    19.1 internet media type message/http and application/http ......164
    19.2 internet media type multipart/byteranges ...................165
    19.3 tolerant applications ......................................166
    19.4 differences between http entities and rfc 2045 entities ....167

    fielding, et al. standards track [page 6]

    rfc 2616 http/1.1 june 1999

    19.4.1 mime-version ............................................167
    19.4.2 conversion to canonical form ............................167
    19.4.3 conversion of date formats ..............................168
    19.4.4 introduction of content-encoding ........................168
    19.4.5 no content-transfer-encoding ............................168
    19.4.6 introduction of transfer-encoding .......................169
    19.4.7 mhtml and line length limitations .......................169
    19.5 additional features ........................................169
    19.5.1 content-disposition .....................................170
    19.6 compatibility with previous versions .......................170
    19.6.1 changes from http/1.0 ...................................171
    19.6.2 compatibility with http/1.0 persistent connections ......172
    19.6.3 changes from rfc 2068 ...................................172
    20 index .......................................................175
    21 full copyright statement ....................................176

    1 introduction

    1.1 purpose

    the hypertext transfer protocol (http) is an application-level
    protocol for distributed, collaborative, hypermedia information
    systems. http has been in use by the world-wide web global
    information initiative since 1990. the first version of http,
    referred to as http/0.9, was a simple protocol for raw data transfer
    across the internet. http/1.0, as defined by rfc 1945 [6], improved
    the protocol by allowing messages to be in the format of mime-like
    messages, containing metainformation about the data transferred and
    modifiers on the request/response semantics. however, http/1.0 does
    not sufficiently take into consideration the effects of hierarchical
    proxies, caching, the need for persistent connections, or virtual
    hosts. in addition, the proliferation of incompletely-implemented
    applications calling themselves "http/1.0" has necessitated a
    protocol version change in order for two communicating applications
    to determine each other's true capabilities.

    this specification defines the protocol referred to as "http/1.1".
    this protocol includes more stringent requirements than http/1.0 in
    order to ensure reliable implementation of its features.

    practical information systems require more functionality than simple
    retrieval, including search, front-end update, and annotation. http
    allows an open-ended set of methods and headers that indicate the
    purpose of a request [47]. it builds on the discipline of reference
    provided by the uniform resource identifier (uri) [3], as a location
    (url) [4] or name (urn) [20], for indicating the resource to which a

    fielding, et al. standards track [page 7]

    rfc 2616 http/1.1 june 1999

    method is to be applied. messages are passed in a format similar to
    that used by internet mail [9] as defined by the multipurpose
    internet mail extensions (mime) [7].

    http is also used as a generic protocol for communication between
    user agents and proxies/gateways to other internet systems, including
    those supported by the smtp [16], nntp [13], ftp [18], gopher [2],
    and wais [10] protocols. in this way, http allows basic hypermedia
    access to resources available from diverse applications.

    1.2 requirements

    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 rfc 2119 [34].

    an implementation is not compliant if it fails to satisfy one or more
    of the must or required level requirements for the protocols it
    implements. an implementation that satisfies all the must or required
    level and all the should level requirements for its protocols is said
    to be "unconditionally compliant"; one that satisfies all the must
    level requirements but not all the should level requirements for its
    protocols is said to be "conditionally compliant."

    1.3 terminology

    this specification uses a number of terms to refer to the roles
    played by participants in, and objects of, the http communication.

    connection
    a transport layer virtual circuit established between two programs
    for the purpose of communication.

    message
    the basic unit of http communication, consisting of a structured
    sequence of octets matching the syntax defined in section 4 and
    transmitted via the connection.

    request
    an http request message, as defined in section 5.

    response
    an http response message, as defined in section 6.

    fielding, et al. standards track [page 8]

    rfc 2616 http/1.1 june 1999

    resource
    a network data object or service that can be identified by a uri,
    as defined in section 3.2. resources may be available in multiple
    representations (e.g. multiple languages, data formats, size, and
    resolutions) or vary in other ways.

    entity
    the information transferred as the payload of a request or
    response. an entity consists of metainformation in the form of
    entity-header fields and content in the form of an entity-body, as
    described in section 7.

    representation
    an entity included with a response that is subject to content
    negotiation, as described in section 12. there may exist multiple
    representations associated with a particular response status.

    content negotiation
    the mechanism for selecting the appropriate representation when
    servicing a request, as described in section 12. the
    representation of entities in any response can be negotiated
    (including error responses).

    variant
    a resource may have one, or more than one, representation(s)
    associated with it at any given instant. each of these
    representations is termed a varriant'. use of the termvariant'
    does not necessarily imply that the resource is subject to content
    negotiation.

    client
    a program that establishes connections for the purpose of sending
    requests.

    user agent
    the client which initiates a request. these are often browsers,
    editors, spiders (web-traversing robots), or other end user tools.

    server
    an application program that accepts connections in order to
    service requests by sending back responses. any given program may
    be capable of being both a client and a server; our use of these
    terms refers only to the role being performed by the program for a
    particular connection, rather than to the program's capabilities
    in general. likewise, any server may act as an origin server,
    proxy, gateway, or tunnel, switching behavior based on the nature
    of each request.

    fielding, et al. standards track [page 9]

    rfc 2616 http/1.1 june 1999

    origin server
    the server on which a given resource resides or is to be created.

    proxy
    an intermediary program which acts as both a server and a client
    for the purpose of making requests on behalf of other clients.
    requests are serviced internally or by passing them on, with
    possible translation, to other servers. a proxy must implement
    both the client and server requirements of this specification. a
    "transparent proxy" is a proxy that does not modify the request or
    response beyond what is required for proxy authentication and
    identification. a "non-transparent proxy" is a proxy that modifies
    the request or response in order to provide some added service to
    the user agent, such as group annotation services, media type
    transformation, protocol reduction, or anonymity filtering. except
    where either transparent or non-transparent behavior is explicitly
    stated, the http proxy requirements apply to both types of
    proxies.

    gateway
    a server which acts as an intermediary for some other server.
    unlike a proxy, a gateway receives requests as if it were the
    origin server for the requested resource; the requesting client
    may not be aware that it is communicating with a gateway.

    tunnel
    an intermediary program which is acting as a blind relay between
    two connections. once active, a tunnel is not considered a party
    to the http communication, though the tunnel may have been
    initiated by an http request. the tunnel ceases to exist when both
    ends of the relayed connections are closed.

    cache
    a program's local store of response messages and the subsystem
    that controls its message storage, retrieval, and deletion. a
    cache stores cacheable responses in order to reduce the response
    time and network bandwidth consumption on future, equivalent
    requests. any client or server may include a cache, though a cache
    cannot be used by a server that is acting as a tunnel.

    cacheable
    a response is cacheable if a cache is allowed to store a copy of
    the response message for use in answering subsequent requests. the
    rules for determining the cacheability of http responses are
    defined in section 13. even if a resource is cacheable, there may
    be additional constraints on whether a cache can use the cached
    copy for a particular request.

    fielding, et al. standards track [page 10]

    rfc 2616 http/1.1 june 1999

    first-hand
    a response is first-hand if it comes directly and without
    unnecessary delay from the origin server, perhaps via one or more
    proxies. a response is also first-hand if its validity has just
    been checked directly with the origin server.

    explicit expiration time
    the time at which the origin server intends that an entity should
    no longer be returned by a cache without further validation.

    heuristic expiration time
    an expiration time assigned by a cache when no explicit expiration
    time is available.

    age
    the age of a response is the time since it was sent by, or
    successfully validated with, the origin server.

    freshness lifetime
    the length of time between the generation of a response and its
    expiration time.

    fresh
    a response is fresh if its age has not yet exceeded its freshness
    lifetime.

    stale
    a response is stale if its age has passed its freshness lifetime.

    semantically transparent
    a cache behaves in a "semantically transparent" manner, with
    respect to a particular response, when its use affects neither the
    requesting client nor the origin server, except to improve
    performance. when a cache is semantically transparent, the client
    receives exactly the same response (except for hop-by-hop headers)
    that it would have received had its request been handled directly
    by the origin server.

    validator
    a protocol element (e.g., an entity tag or a last-modified time)
    that is used to find out whether a cache entry is an equivalent
    copy of an entity.

    upstream/downstream
    upstream and downstream describe the flow of a message: all
    messages flow from upstream to downstream.

    fielding, et al. standards track [page 11]

    rfc 2616 http/1.1 june 1999

    inbound/outbound
    inbound and outbound refer to the request and response paths for
    messages: "inbound" means "traveling toward the origin server",
    and "outbound" means "traveling toward the user agent"

    1.4 overall operation

    the http protocol is a request/response protocol. a client sends a
    request to the server in the form of a request method, uri, and
    protocol version, followed by a mime-like message containing request
    modifiers, client information, and possible body content over a
    connection with a server. the server responds with a status line,
    including the message's protocol version and a success or error code,
    followed by a mime-like message containing server information, entity
    metainformation, and possible entity-body content. the relationship
    between http and mime is described in appendix 19.4.

    most http communication is initiated by a user agent and consists of
    a request to be applied to a resource on some origin server. in the
    simplest case, this may be accomplished via a single connection (v)
    between the user agent (ua) and the origin server (o).

    request chain ------------------------>
    ua -------------------v------------------- o
    <----------------------- response chain

    a more complicated situation occurs when one or more intermediaries
    are present in the request/response chain. there are three common
    forms of intermediary: proxy, gateway, and tunnel. a proxy is a
    forwarding agent, receiving requests for a uri in its absolute form,
    rewriting all or part of the message, and forwarding the reformatted
    request toward the server identified by the uri. a gateway is a
    receiving agent, acting as a layer above some other server(s) and, if
    necessary, translating the requests to the underlying server's
    protocol. a tunnel acts as a relay point between two connections
    without changing the messages; tunnels are used when the
    communication needs to pass through an intermediary (such as a
    firewall) even when the intermediary cannot understand the contents
    of the messages.

    request chain -------------------------------------->
    ua -----v----- a -----v----- b -----v----- c -----v----- o
    <------------------------------------- response chain

    the figure above shows three intermediaries (a, b, and c) between the
    user agent and origin server. a request or response message that
    travels the whole chain will pass through four separate connections.
    this distinction is important because some http communication options

    fielding, et al. standards track [page 12]

    rfc 2616 http/1.1 june 1999

    may apply only to the connection with the nearest, non-tunnel
    neighbor, only to the end-points of the chain, or to all connections
    along the chain. although the diagram is linear, each participant may
    be engaged in multiple, simultaneous communications. for example, b
    may be receiving requests from many clients other than a, and/or
    forwarding requests to servers other than c, at the same time that it
    is handling a's request.

    any party to the communication which is not acting as a tunnel may
    employ an internal cache for handling requests. the effect of a cache
    is that the request/response chain is shortened if one of the
    participants along the chain has a cached response applicable to that
    request. the following illustrates the resulting chain if b has a
    cached copy of an earlier response from o (via c) for a request which
    has not been cached by ua or a.

    request chain ---------->
    ua -----v----- a -----v----- b - - - - - - c - - - - - - o
    <--------- response chain

    not all responses are usefully cacheable, and some requests may
    contain modifiers which place special requirements on cache behavior.
    http requirements for cache behavior and cacheable responses are
    defined in section 13.

    in fact, there are a wide variety of architectures and configurations
    of caches and proxies currently being experimented with or deployed
    across the world wide web. these systems include national hierarchies
    of proxy caches to save transoceanic bandwidth, systems that
    broadcast or multicast cache entries, organizations that distribute
    subsets of cached data via cd-rom, and so on. http systems are used
    in corporate intranets over high-bandwidth links, and for access via
    pdas with low-power radio links and intermittent connectivity. the
    goal of http/1.1 is to support the wide diversity of configurations
    already deployed while introducing protocol constructs that meet the
    needs of those who build web applications that require high
    reliability and, failing that, at least reliable indications of
    failure.

    http communication usually takes place over tcp/ip connections. the
    default port is tcp 80 [19], but other ports can be used. this does
    not preclude http from being implemented on top of any other protocol
    on the internet, or on other networks. http only presumes a reliable
    transport; any protocol that provides such guarantees can be used;
    the mapping of the http/1.1 request and response structures onto the
    transport data units of the protocol in question is outside the scope
    of this specification.

    fielding, et al. standards track [page 13]

    rfc 2616 http/1.1 june 1999

    in http/1.0, most implementations used a new connection for each
    request/response exchange. in http/1.1, a connection may be used for
    one or more request/response exchanges, although connections may be
    closed for a variety of reasons (see section 8.1).

    2 notational conventions and generic grammar

    2.1 augmented bnf

    all of the mechanisms specified in this document are described in
    both prose and an augmented backus-naur form (bnf) similar to that
    used by rfc 822 [9]. implementors will need to be familiar with the
    notation in order to understand this specification. the augmented bnf
    includes the following constructs:

    name = definition
    the name of a rule is simply the name itself (without any
    enclosing "<" and ">") and is separated from its definition by the
    equal "=" character. white space is only significant in that
    indentation of continuation lines is used to indicate a rule
    definition that spans more than one line. certain basic rules are
    in uppercase, such as sp, lws, ht, crlf, digit, alpha, etc. angle
    brackets are used within definitions whenever their presence will
    facilitate discerning the use of rule names.

    "literal"
    quotation marks surround literal text. unless stated otherwise,
    the text is case-insensitive.

    rule1 | rule2
    elements separated by a bar ("|") are alternatives, e.g., "yes |
    no" will accept yes or no.

    (rule1 rule2)
    elements enclosed in parentheses are treated as a single element.
    thus, "(elem (foo | bar) elem)" allows the token sequences "elem
    foo elem" and "elem bar elem".

    *rule
    the character "*" preceding an element indicates repetition. the
    full form is "<n>*<m>element" indicating at least <n> and at most
    <m> occurrences of element. default values are 0 and infinity so
    that "*(element)" allows any number, including zero; "1*element"
    requires at least one; and "1*2element" allows one or two.

    [rule]
    square brackets enclose optional elements; "[foo bar]" is
    equivalent to "*1(foo bar)".

    fielding, et al. standards track [page 14]

    rfc 2616 http/1.1 june 1999

    n rule
    specific repetition: "<n>(element)" is equivalent to
    "<n>*<n>(element)"; that is, exactly <n> occurrences of (element).
    thus 2digit is a 2-digit number, and 3alpha is a string of three
    alphabetic characters.

    #rule
    a construct "#" is defined, similar to "*", for defining lists of
    elements. the full form is "<n>#<m>element" indicating at least
    <n> and at most <m> elements, each separated by one or more commas
    (",") and optional linear white space (lws). this makes the usual
    form of lists very easy; a rule such as
    ( *lws element *( *lws "," *lws element ))
    can be shown as
    1#element
    wherever this construct is used, null elements are allowed, but do
    not contribute to the count of elements present. that is,
    "(element), , (element) " is permitted, but counts as only two
    elements. therefore, where at least one element is required, at
    least one non-null element must be present. default values are 0
    and infinity so that "#element" allows any number, including zero;
    "1#element" requires at least one; and "1#2element" allows one or
    two.

    ; comment
    a semi-colon, set off some distance to the right of rule text,
    starts a comment that continues to the end of line. this is a
    simple way of including useful notes in parallel with the
    specifications.

    implied *lws
    the grammar described by this specification is word-based. except
    where noted otherwise, linear white space (lws) can be included
    between any two adjacent words (token or quoted-string), and
    between adjacent words and separators, without changing the
    interpretation of a field. at least one delimiter (lws and/or

    separators) must exist between any two tokens (for the definition
    of "token" below), since they would otherwise be interpreted as a
    single token.

    2.2 basic rules

    the following rules are used throughout this specification to
    describe basic parsing constructs. the us-ascii coded character set
    is defined by ansi x3.4-1986 [21].

    fielding, et al. standards track [page 15]

    rfc 2616 http/1.1 june 1999

    octet = <any 8-bit sequence of data>
    char = <any us-ascii character (octets 0 - 127)>
    upalpha = <any us-ascii uppercase letter "a".."z">
    loalpha = <any us-ascii lowercase letter "a".."z">
    alpha = upalpha | loalpha
    digit = <any us-ascii digit "0".."9">
    ctl = <any us-ascii control character
    (octets 0 - 31) and del (127)>
    cr = <us-ascii cr, carriage return (13)>
    lf = <us-ascii lf, linefeed (10)>
    sp = <us-ascii sp, space (32)>
    ht = <us-ascii ht, horizontal-tab (9)>
    <"> = <us-ascii double-quote mark (34)>

    http/1.1 defines the sequence cr lf as the end-of-line marker for all
    protocol elements except the entity-body (see appendix 19.3 for
    tolerant applications). the end-of-line marker within an entity-body
    is defined by its associated media type, as described in section 3.7.

    crlf = cr lf

    http/1.1 header field values can be folded onto multiple lines if the
    continuation line begins with a space or horizontal tab. all linear
    white space, including folding, has the same semantics as sp. a
    recipient may replace any linear white space with a single sp before
    interpreting the field value or forwarding the message downstream.

    lws = [crlf] 1*( sp | ht )

    the text rule is only used for descriptive field contents and values
    that are not intended to be interpreted by the message parser. words
    of *text may contain characters from character sets other than iso-
    8859-1 [22] only when encoded according to the rules of rfc 2047
    [14].

    text = <any octet except ctls,
    but including lws>

    a crlf is allowed in the definition of text only as part of a header
    field continuation. it is expected that the folding lws will be
    replaced with a single sp before interpretation of the text value.

    hexadecimal numeric characters are used in several protocol elements.

    hex = "a" | "b" | "c" | "d" | "e" | "f"
    | "a" | "b" | "c" | "d" | "e" | "f" | digit

    fielding, et al. standards track [page 16]

    rfc 2616 http/1.1 june 1999

    many http/1.1 header field values consist of words separated by lws
    or special characters. these special characters must be in a quoted
    string to be used within a parameter value (as defined in section
    3.6).

    token = 1*<any char except ctls or separators>
    separators = "(" | ")" | "<" | ">" | "@"
    | "," | ";" | ":" | "\" | <">
    | "/" | "[" | "]" | "?" | "="
    | "{" | "}" | sp | ht

    comments can be included in some http header fields by surrounding
    the comment text with parentheses. comments are only allowed in
    fields containing "comment" as part of their field value definition.
    in all other fields, parentheses are considered part of the field
    value.

    comment = "(" *( ctext | quoted-pair | comment ) ")"
    ctext = <any text excluding "(" and ")">

    a string of text is parsed as a single word if it is quoted using
    double-quote marks.

    quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
    qdtext = <any text except <">>

    the backslash character ("\") may be used as a single-character
    quoting mechanism only within quoted-string and comment constructs.

    quoted-pair = "\" char

    3 protocol parameters

    3.1 http version

    http uses a "<major>.<minor>" numbering scheme to indicate versions
    of the protocol. the protocol versioning policy is intended to allow
    the sender to indicate the format of a message and its capacity for
    understanding further http communication, rather than the features
    obtained via that communication. no change is made to the version
    number for the addition of message components which do not affect
    communication behavior or which only add to extensible field values.
    the <minor> number is incremented when the changes made to the
    protocol add features which do not change the general message parsing
    algorithm, but which may add to the message semantics and imply
    additional capabilities of the sender. the <major> number is
    incremented when the format of a message within the protocol is
    changed. see rfc 2145 [36] for a fuller explanation.

    fielding, et al. standards track [page 17]

    rfc 2616 http/1.1 june 1999

    the version of an http message is indicated by an http-version field
    in the first line of the message.

    http-version = "http" "/" 1*digit "." 1*digit

    note that the major and minor numbers must be treated as separate
    integers and that each may be incremented higher than a single digit.
    thus, http/2.4 is a lower version than http/2.13, which in turn is
    lower than http/12.3. leading zeros must be ignored by recipients and
    must not be sent.

    an application that sends a request or response message that includes
    http-version of "http/1.1" must be at least conditionally compliant
    with this specification. applications that are at least conditionally
    compliant with this specification should use an http-version of
    "http/1.1" in their messages, and must do so for any message that is
    not compatible with http/1.0. for more details on when to send
    specific http-version values, see rfc 2145 [36].

    the http version of an application is the highest http version for
    which the application is at least conditionally compliant.

    proxy and gateway applications need to be careful when forwarding
    messages in protocol versions different from that of the application.
    since the protocol version indicates the protocol capability of the
    sender, a proxy/gateway must not send a message with a version
    indicator which is greater than its actual version. if a higher
    version request is received, the proxy/gateway must either downgrade
    the request version, or respond with an error, or switch to tunnel
    behavior.

    due to interoperability problems with http/1.0 proxies discovered
    since the publication of rfc 2068[33], caching proxies must, gateways
    may, and tunnels must not upgrade the request to the highest version
    they support. the proxy/gateway's response to that request must be in
    the same major version as the request.

    note: converting between versions of http may involve modification
    of header fields required or forbidden by the versions involved.

    3.2 uniform resource identifiers

    uris have been known by many names: www addresses, universal document
    identifiers, universal resource identifiers [3], and finally the
    combination of uniform resource locators (url) [4] and names (urn)
    [20]. as far as http is concerned, uniform resource identifiers are
    simply formatted strings which identify--via name, location, or any
    other characteristic--a resource.

    fielding, et al. standards track [page 18]

    rfc 2616 http/1.1 june 1999

    3.2.1 general syntax

    uris in http can be represented in absolute form or relative to some
    known base uri [11], depending upon the context of their use. the two
    forms are differentiated by the fact that absolute uris always begin
    with a scheme name followed by a colon. for definitive information on
    url syntax and semantics, see "uniform resource identifiers (uri):
    generic syntax and semantics," rfc 2396 [42] (which replaces rfcs
    1738 [4] and rfc 1808 [11]). this specification adopts the
    definitions of "uri-reference", "absoluteuri", "relativeuri", "port",
    "host","abs_path", "rel_path", and "authority" from that
    specification.

    the http protocol does not place any a priori limit on the length of
    a uri. servers must be able to handle the uri of any resource they
    serve, and should be able to handle uris of unbounded length if they
    provide get-based forms that could generate such uris. a server
    should return 414 (request-uri too long) status if a uri is longer
    than the server can handle (see section 10.4.15).

    note: servers ought to be cautious about depending on uri lengths
    above 255 bytes, because some older client or proxy
    implementations might not properly support these lengths.

    3.2.2 http url

    the "http" scheme is used to locate network resources via the http
    protocol. this section defines the scheme-specific syntax and
    semantics for http urls.

    http_url = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]

    if the port is empty or not given, port 80 is assumed. the semantics
    are that the identified resource is located at the server listening
    for tcp connections on that port of that host, and the request-uri
    for the resource is abs_path (section 5.1.2). the use of ip addresses
    in urls should be avoided whenever possible (see rfc 1900 [24]). if
    the abs_path is not present in the url, it must be given as "/" when
    used as a request-uri for a resource (section 5.1.2). if a proxy
    receives a host name which is not a fully qualified domain name, it
    may add its domain to the host name it received. if a proxy receives
    a fully qualified domain name, the proxy must not change the host
    name.

    fielding, et al. standards track [page 19]

    rfc 2616 http/1.1 june 1999

    3.2.3 uri comparison

    when comparing two uris to decide if they match or not, a client
    should use a case-sensitive octet-by-octet comparison of the entire
    uris, with these exceptions:

    - a port that is empty or not given is equivalent to the default
    port for that uri-reference;

    - comparisons of host names must be case-insensitive;

    - comparisons of scheme names must be case-insensitive;

    - an empty abs_path is equivalent to an abs_path of "/".

    characters other than those in the "reserved" and "unsafe" sets (see
    rfc 2396 [42]) are equivalent to their ""%" hex hex" encoding.

    for example, the following three uris are equivalent:

    http://abc.com/~smith/home.html
    http://abc.com/~smith/home.html
    http://abc.com/:/%7esmith/home.html

    3.3 date/time formats

    3.3.1 full date

    http applications have historically allowed three different formats
    for the representation of date/time stamps:

    sun, 06 nov 1994 08:49:37 gmt ; rfc 822, updated by rfc 1123
    sunday, 06-nov-94 08:49:37 gmt ; rfc 850, obsoleted by rfc 1036
    sun nov 6 08:49:37 1994 ; ansi c's asctime() format

    the first format is preferred as an internet standard and represents
    a fixed-length subset of that defined by rfc 1123 [8] (an update to
    rfc 822 [9]). the second format is in common use, but is based on the
    obsolete rfc 850 [12] date format and lacks a four-digit year.
    http/1.1 clients and servers that parse the date value must accept
    all three formats (for compatibility with http/1.0), though they must
    only generate the rfc 1123 format for representing http-date values
    in header fields. see section 19.3 for further information.

    note: recipients of date values are encouraged to be robust in
    accepting date values that may have been sent by non-http
    applications, as is sometimes the case when retrieving or posting
    messages via proxies/gateways to smtp or nntp.

    fielding, et al. standards track [page 20]

    rfc 2616 http/1.1 june 1999

    all http date/time stamps must be represented in greenwich mean time
    (gmt), without exception. for the purposes of http, gmt is exactly
    equal to utc (coordinated universal time). this is indicated in the
    first two formats by the inclusion of "gmt" as the three-letter
    abbreviation for time zone, and must be assumed when reading the
    asctime format. http-date is case sensitive and must not include
    additional lws beyond that specifically included as sp in the
    grammar.

    http-date = rfc1123-date | rfc850-date | asctime-date
    rfc1123-date = wkday "," sp date1 sp time sp "gmt"
    rfc850-date = weekday "," sp date2 sp time sp "gmt"
    asctime-date = wkday sp date3 sp time sp 4digit
    date1 = 2digit sp month sp 4digit
    ; day month year (e.g., 02 jun 1982)
    date2 = 2digit "-" month "-" 2digit
    ; day-month-year (e.g., 02-jun-82)
    date3 = month sp ( 2digit | ( sp 1digit ))
    ; month day (e.g., jun 2)
    time = 2digit ":" 2digit ":" 2digit
    ; 00:00:00 - 23:59:59
    wkday = "mon" | "tue" | "wed"
    | "thu" | "fri" | "sat" | "sun"
    weekday = "monday" | "tuesday" | "wednesday"
    | "thursday" | "friday" | "saturday" | "sunday"
    month = "jan" | "feb" | "mar" | "apr"
    | "may" | "jun" | "jul" | "aug"
    | "sep" | "oct" | "nov" | "dec"

    note: http requirements for the date/time stamp format apply only
    to their usage within the protocol stream. clients and servers are
    not required to use these formats for user presentation, request
    logging, etc.

    3.3.2 delta seconds

    some http header fields allow a time value to be specified as an
    integer number of seconds, represented in decimal, after the time
    that the message was received.

    delta-seconds = 1*digit

    3.4 character sets

    http uses the same definition of the term "character set" as that
    described for mime:
  • fielding, et al. standards track [page 21]

    rfc 2616 http/1.1 june 1999

    the term "character set" is used in this document to refer to a
    method used with one or more tables to convert a sequence of octets
    into a sequence of characters. note that unconditional conversion in
    the other direction is not required, in that not all characters may
    be available in a given character set and a character set may provide
    more than one sequence of octets to represent a particular character.
    this definition is intended to allow various kinds of character
    encoding, from simple single-table mappings such as us-ascii to
    complex table switching methods such as those that use iso-2022's
    techniques. however, the definition associated with a mime character
    set name must fully specify the mapping to be performed from octets
    to characters. in particular, use of external profiling information
    to determine the exact mapping is not permitted.

    note: this use of the term "character set" is more commonly
    referred to as a "character encoding." however, since http and
    mime share the same registry, it is important that the terminology
    also be shared.

    http character sets are identified by case-insensitive tokens. the
    complete set of tokens is defined by the iana character set registry
    [19].

    charset = token

    although http allows an arbitrary token to be used as a charset
    value, any token that has a predefined value within the iana
    character set registry [19] must represent the character set defined
    by that registry. applications should limit their use of character
    sets to those defined by the iana registry.

    implementors should be aware of ietf character set requirements [38]
    [41].

    3.4.1 missing charset

    some http/1.0 software has interpreted a content-type header without
    charset parameter incorrectly to mean "recipient should guess."
    senders wishing to defeat this behavior may include a charset
    parameter even when the charset is iso-8859-1 and should do so when
    it is known that it will not confuse the recipient.

    unfortunately, some older http/1.0 clients did not deal properly with
    an explicit charset parameter. http/1.1 recipients must respect the
    charset label provided by the sender; and those user agents that have
    a provision to "guess" a charset must use the charset from the

    fielding, et al. standards track [page 22]

    rfc 2616 http/1.1 june 1999

    content-type field if they support that charset, rather than the
    recipient's preference, when initially displaying a document. see
    section 3.7.1.

    3.5 content codings

    content coding values indicate an encoding transformation that has
    been or can be applied to an entity. content codings are primarily
    used to allow a document to be compressed or otherwise usefully
    transformed without losing the identity of its underlying media type
    and without loss of information. frequently, the entity is stored in
    coded form, transmitted directly, and only decoded by the recipient.

    content-coding = token

    all content-coding values are case-insensitive. http/1.1 uses
    content-coding values in the accept-encoding (section 14.3) and
    content-encoding (section 14.11) header fields. although the value
    describes the content-coding, what is more important is that it
    indicates what decoding mechanism will be required to remove the
    encoding.

    the internet assigned numbers authority (iana) acts as a registry for
    content-coding value tokens. initially, the registry contains the
    following tokens:

    gzip an encoding format produced by the file compression program
    "gzip" (gnu zip) as described in rfc 1952 [25]. this format is a
    lempel-ziv coding (lz77) with a 32 bit crc.

    compress
    the encoding format produced by the common unix file compression
    program "compress". this format is an adaptive lempel-ziv-welch
    coding (lzw).

    use of program names for the identification of encoding formats
    is not desirable and is discouraged for future encodings. their
    use here is representative of historical practice, not good
    design. for compatibility with previous implementations of http,
    applications should consider "x-gzip" and "x-compress" to be
    equivalent to "gzip" and "compress" respectively.

    deflate
    the "zlib" format defined in rfc 1950 [31] in combination with
    the "deflate" compression mechanism described in rfc 1951 [29].

    fielding, et al. standards track [page 23]

    rfc 2616 http/1.1 june 1999

    identity
    the default (identity) encoding; the use of no transformation
    whatsoever. this content-coding is used only in the accept-
    encoding header, and should not be used in the content-encoding
    header.

    new content-coding value tokens should be registered; to allow
    interoperability between clients and servers, specifications of the
    content coding algorithms needed to implement a new value should be
    publicly available and adequate for independent implementation, and
    conform to the purpose of content coding defined in this section.

    3.6 transfer codings

    transfer-coding values are used to indicate an encoding
    transformation that has been, can be, or may need to be applied to an
    entity-body in order to ensure "safe transport" through the network.
    this differs from a content coding in that the transfer-coding is a
    property of the message, not of the original entity.

    transfer-coding = "chunked" | transfer-extension
    transfer-extension = token *( ";" parameter )

    parameters are in the form of attribute/value pairs.

    parameter = attribute "=" value
    attribute = token
    value = token | quoted-string

    all transfer-coding values are case-insensitive. http/1.1 uses
    transfer-coding values in the te header field (section 14.39) and in
    the transfer-encoding header field (section 14.41).

    whenever a transfer-coding is applied to a message-body, the set of
    transfer-codings must include "chunked", unless the message is
    terminated by closing the connection. when the "chunked" transfer-
    coding is used, it must be the last transfer-coding applied to the
    message-body. the "chunked" transfer-coding must not be applied more
    than once to a message-body. these rules allow the recipient to
    determine the transfer-length of the message (section 4.4).

    transfer-codings are analogous to the content-transfer-encoding
    values of mime [7], which were designed to enable safe transport of
    binary data over a 7-bit transport service. however, safe transport
    has a different focus for an 8bit-clean transfer protocol. in http,
    the only unsafe characteristic of message-bodies is the difficulty in
    determining the exact body length (section 7.2.2), or the desire to
    encrypt data over a shared transport.

    fielding, et al. standards track [page 24]

    rfc 2616 http/1.1 june 1999

    the internet assigned numbers authority (iana) acts as a registry for
    transfer-coding value tokens. initially, the registry contains the
    following tokens: "chunked" (section 3.6.1), "identity" (section
    3.6.2), "gzip" (section 3.5), "compress" (section 3.5), and "deflate"
    (section 3.5).

    new transfer-coding value tokens should be registered in the same way
    as new content-coding value tokens (section 3.5).

    a server which receives an entity-body with a transfer-coding it does
    not understand should return 501 (unimplemented), and close the
    connection. a server must not send transfer-codings to an http/1.0
    client.

    3.6.1 chunked transfer coding

    the chunked encoding modifies the body of a message in order to
    transfer it as a series of chunks, each with its own size indicator,
    followed by an optional trailer containing entity-header fields. this
    allows dynamically produced content to be transferred along with the
    information necessary for the recipient to verify that it has
    received the full message.

    chunked-body = *chunk
    last-chunk
    trailer
    crlf

    chunk = chunk-size [ chunk-extension ] crlf
    chunk-data crlf
    chunk-size = 1*hex
    last-chunk = 1*("0") [ chunk-extension ] crlf

    chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] )
    chunk-ext-name = token
    chunk-ext-val = token | quoted-string
    chunk-data = chunk-size(octet)
    trailer = *(entity-header crlf)

    the chunk-size field is a string of hex digits indicating the size of
    the chunk. the chunked encoding is ended by any chunk whose size is
    zero, followed by the trailer, which is terminated by an empty line.

    the trailer allows the sender to include additional http header
    fields at the end of the message. the trailer header field can be
    used to indicate which header fields are included in a trailer (see
    section 14.40).

    fielding, et al. standards track [page 25]

    rfc 2616 http/1.1 june 1999

    a server using chunked transfer-coding in a response must not use the
    trailer for any header fields unless at least one of the following is
    true:

    a)the request included a te header field that indicates "trailers" is
    acceptable in the transfer-coding of the response, as described in
    section 14.39; or,

    b)the server is the origin server for the response, the trailer
    fields consist entirely of optional metadata, and the recipient
    could use the message (in a manner acceptable to the origin server)
    without receiving this metadata. in other words, the origin server
    is willing to accept the possibility that the trailer fields might
    be silently discarded along the path to the client.

    this requirement prevents an interoperability failure when the
    message is being received by an http/1.1 (or later) proxy and
    forwarded to an http/1.0 recipient. it avoids a situation where
    compliance with the protocol would have necessitated a possibly
    infinite buffer on the proxy.

    an example process for decoding a chunked-body is presented in
    appendix 19.4.6.

    all http/1.1 applications must be able to receive and decode the
    "chunked" transfer-coding, and must ignore chunk-extension extensions
    they do not understand.

    3.7 media types

    http uses internet media types [17] in the content-type (section
    14.17) and accept (section 14.1) header fields in order to provide
    open and extensible data typing and type negotiation.

    media-type = type "/" subtype *( ";" parameter )
    type = token
    subtype = token

    parameters may follow the type/subtype in the form of attribute/value
    pairs (as defined in section 3.6).

    the type, subtype, and parameter attribute names are case-
    insensitive. parameter values might or might not be case-sensitive,
    depending on the semantics of the parameter name. linear white space
    (lws) must not be used between the type and subtype, nor between an
    attribute and its value. 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.

    fielding, et al. standards track [page 26]

    rfc 2616 http/1.1 june 1999

    note that some older http applications do not recognize media type
    parameters. when sending data to older http applications,
    implementations should only use media type parameters when they are
    required by that type/subtype definition.

    media-type values are registered with the internet assigned number
    authority (iana [19]). the media type registration process is
    outlined in rfc 1590 [17]. use of non-registered media types is
    discouraged.

    3.7.1 canonicalization and text defaults

    internet media types are registered with a canonical form. an
    entity-body transferred via http messages must be represented in the
    appropriate canonical form prior to its transmission except for
    "text" types, as defined in the next paragraph.

    when in canonical form, media subtypes of the "text" type use crlf as
    the text line break. http relaxes this requirement and allows the
    transport of text media with plain cr or lf alone representing a line
    break when it is done consistently for an entire entity-body. http
    applications must accept crlf, bare cr, and bare lf as being
    representative of a line break in text media received via http. in
    addition, if the text is represented in a character set that does not
    use octets 13 and 10 for cr and lf respectively, as is the case for
    some multi-byte character sets, http allows the use of whatever octet
    sequences are defined by that character set to represent the
    equivalent of cr and lf for line breaks. this flexibility regarding
    line breaks applies only to text media in the entity-body; a bare cr
    or lf must not be substituted for crlf within any of the http control
    structures (such as header fields and multipart boundaries).

    if an entity-body is encoded with a content-coding, the underlying
    data must be in a form defined above prior to being encoded.

    the "charset" parameter is used with some media types to define the
    character set (section 3.4) of the data. when no explicit charset
    parameter is provided by the sender, media subtypes of the "text"
    type are defined to have a default charset value of "iso-8859-1" when
    received via http. data in character sets other than "iso-8859-1" or
    its subsets must be labeled with an appropriate charset value. see
    section 3.4.1 for compatibility problems.

    3.7.2 multipart types

    mime provides for a number of "multipart" types -- encapsulations of
    one or more entities within a single message-body. all multipart
    types share a common syntax, as defined in section 5.1.1 of rfc 2046

    fielding, et al. standards track [page 27]

    rfc 2616 http/1.1 june 1999

    [40], and must include a boundary parameter as part of the media type
    value. the message body is itself a protocol element and must
    therefore use only crlf to represent line breaks between body-parts.
    unlike in rfc 2046, the epilogue of any multipart message must be
    empty; http applications must not transmit the epilogue (even if the
    original multipart contains an epilogue). these restrictions exist in
    order to preserve the self-delimiting nature of a multipart message-
    body, wherein the "end" of the message-body is indicated by the
    ending multipart boundary.

    in general, http treats a multipart message-body no differently than
    any other media type: strictly as payload. the one exception is the
    "multipart/byteranges" type (appendix 19.2) when it appears in a 206
    (partial content) response, which will be interpreted by some http
    caching mechanisms as described in sections 13.5.4 and 14.16. in all
    other cases, an http user agent should follow the same or similar
    behavior as a mime user agent would upon receipt of a multipart type.
    the mime header fields within each body-part of a multipart message-
    body do not have any significance to http beyond that defined by
    their mime semantics.

    in general, an http user agent should follow the same or similar
    behavior as a mime user agent would upon receipt of a multipart type.
    if an application receives an unrecognized multipart subtype, the
    application must treat it as being equivalent to "multipart/mixed".

    note: the "multipart/form-data" type has been specifically defined
    for carrying form data suitable for processing via the post
    request method, as described in rfc 1867 [15].

    3.8 product tokens

    product tokens are used to allow communicating applications to
    identify themselves by software name and version. most fields using
    product tokens also allow sub-products which form a significant part
    of the application to be listed, separated by white space. by
    convention, the products are listed in order of their significance
    for identifying the application.

    product = token ["/" product-version]
    product-version = token

    examples:

    user-agent: cern-linemode/2.15 libwww/2.17b3
    server: apache/0.8.4

    fielding, et al. standards track [page 28]

    rfc 2616 http/1.1 june 1999

    product tokens should be short and to the point. they must not be
    used for advertising or other non-essential information. although any
    token character may appear in a product-version, this token should
    only be used for a version identifier (i.e., successive versions of
    the same product should only differ in the product-version portion of
    the product value).

    3.9 quality values

    http content negotiation (section 12) uses short "floating point"
    numbers to indicate the relative importance ("weight") of various
    negotiable parameters. a weight is normalized to a real number in
    the range 0 through 1, where 0 is the minimum and 1 the maximum
    value. if a parameter has a quality value of 0, then content with
    this parameter is `not acceptable' for the client. http/1.1
    applications must not generate more than three digits after the
    decimal point. user configuration of these values should also be
    limited in this fashion.

    qvalue = ( "0" [ "." 0*3digit ] )
    | ( "1" [ "." 0*3("0") ] )

    "quality values" is a misnomer, since these values merely represent
    relative degradation in desired quality.

    3.10 language tags

    a language tag 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 fields.

    the syntax and registry of http language tags is the same as that
    defined by rfc 1766 [1]. in summary, a language tag is composed of 1
    or more parts: a primary language tag and a possibly empty series of
    subtags:

    language-tag = primary-tag *( "-" subtag )
    primary-tag = 1*8alpha
    subtag = 1*8alpha

    white space is not allowed within the tag and all tags are case-
    insensitive. the name space of language tags is administered by the
    iana. example tags include:

    en, en-us, en-cockney, i-cherokee, x-pig-latin

    fielding, et al. standards track [page 29]

    rfc 2616 http/1.1 june 1999

    where any two-letter primary-tag is an iso-639 language abbreviation
    and any two-letter initial subtag is an iso-3166 country code. (the
    last three tags above are not registered tags; all but the last are
    examples of tags which could be registered in future.)

    3.11 entity tags

    entity tags are used for comparing two or more entities from the same
    requested resource. http/1.1 uses entity tags in the etag (section
    14.19), if-match (section 14.24), if-none-match (section 14.26), and
    if-range (section 14.27) header fields. the definition of how they
    are used and compared as cache validators is in section 13.3.3. an
    entity tag consists of an opaque quoted string, possibly prefixed by
    a weakness indicator.

    entity-tag = [ weak ] opaque-tag
    weak = "w/"
    opaque-tag = quoted-string

    a "strong entity tag" may be shared by two entities of a resource
    only if they are equivalent by octet equality.

    a "weak entity tag," indicated by the "w/" prefix, may be shared by
    two entities of a resource only if the entities are equivalent and
    could be substituted for each other with no significant change in
    semantics. a weak entity tag can only be used for weak comparison.

    an entity tag must be unique across all versions of all entities
    associated with a particular resource. a given entity tag value may
    be used for entities obtained by requests on different uris. the use
    of the same entity tag value in conjunction with entities obtained by
    requests on different uris does not imply the equivalence of those
    entities.

    3.12 range units

    http/1.1 allows a client to request that only part (a range of) the
    response entity be included within the response. http/1.1 uses range
    units in the range (section 14.35) and content-range (section 14.16)
    header fields. an entity can be broken down into subranges according
    to various structural units.

    range-unit = bytes-unit | other-range-unit
    bytes-unit = "bytes"
    other-range-unit = token

    the only range unit defined by http/1.1 is "bytes". http/1.1
    implementations may ignore ranges specified using other units.

    fielding, et al. standards track [page 30]

    rfc 2616 http/1.1 june 1999

    http/1.1 has been designed to allow implementations of applications
    that do not depend on knowledge of ranges.

    4 http message

    4.1 message types

    http messages consist of requests from client to server and responses
    from server to client.

    http-message = request | response ; http/1.1 messages

    request (section 5) and response (section 6) messages use the generic
    message format of rfc 822 [9] for transferring entities (the payload
    of the message). both types of message consist of a start-line, zero
    or more header fields (also known as "headers"), an empty line (i.e.,
    a line with nothing preceding the crlf) indicating the end of the
    header fields, and possibly a message-body.

    generic-message = start-line
    *(message-header crlf)
    crlf
    [ message-body ]
    start-line = request-line | status-line

    in the interest of robustness, servers should ignore any empty
    line(s) received where a request-line is expected. in other words, if
    the server is reading the protocol stream at the beginning of a
    message and receives a crlf first, it should ignore the crlf.

    certain buggy http/1.0 client implementations generate extra crlf's
    after a post request. to restate what is explicitly forbidden by the
    bnf, an http/1.1 client must not preface or follow a request with an
    extra crlf.

    4.2 message headers

    http header fields, which include general-header (section 4.5),
    request-header (section 5.3), response-header (section 6.2), and
    entity-header (section 7.1) fields, follow the same generic format as
    that given in section 3.1 of rfc 822 [9]. each header field consists
    of a name followed by a colon (":") and the field value. field names
    are case-insensitive. the field value may be preceded by any amount
    of lws, though a single sp is preferred. header fields can be
    extended over multiple lines by preceding each extra line with at
    least one sp or ht. applications ought to follow "common form", where
    one is known or indicated, when generating http constructs, since
    there might exist some implementations that fail to accept anything
  • fielding, et al. standards track [page 31]

    rfc 2616 http/1.1 june 1999

    beyond the common forms.

    message-header = field-name ":" [ field-value ]
    field-name = token
    field-value = *( field-content | lws )
    field-content = <the octets making up the field-value
    and consisting of either *text or combinations
    of token, separators, and quoted-string>

    the field-content does not include any leading or trailing lws:
    linear white space occurring before the first non-whitespace
    character of the field-value or after the last non-whitespace
    character of the field-value. such leading or trailing lws may be
    removed without changing the semantics of the field value. any lws
    that occurs between field-content may be replaced with a single sp
    before interpreting the field value or forwarding the message
    downstream.

    the order in which header fields with differing field names are
    received is not significant. however, it is "good practice" to send
    general-header fields first, followed by request-header or response-
    header fields, and ending with the entity-header fields.

    multiple message-header fields with the same field-name may be
    present in a message if and only if the entire field-value for that
    header field is defined as a comma-separated list [i.e., #(values)].
    it must be possible to combine the multiple header fields into one
    "field-name: field-value" pair, without changing the semantics of the
    message, by appending each subsequent field-value to the first, each
    separated by a comma. the order in which header fields with the same
    field-name are received is therefore significant to the
    interpretation of the combined field value, and thus a proxy must not
    change the order of these field values when a message is forwarded.

    4.3 message body

    the message-body (if any) of an http message is used to carry the
    entity-body associated with the request or response. the message-body
    differs from the entity-body only when a transfer-coding has been
    applied, as indicated by the transfer-encoding header field (section
    14.41).

    message-body = entity-body
    | <entity-body encoded as per transfer-encoding>

    transfer-encoding must be used to indicate any transfer-codings
    applied by an application to ensure safe and proper transfer of the
    message. transfer-encoding is a property of the message, not of the

    fielding, et al. standards track [page 32]

    rfc 2616 http/1.1 june 1999

    entity, and thus may be added or removed by any application along the
    request/response chain. (however, section 3.6 places restrictions on
    when certain transfer-codings may be used.)

    the rules for when a message-body is allowed in a message differ for
    requests and responses.

    the presence of a message-body in a request is signaled by the
    inclusion of a content-length or transfer-encoding header field in
    the request's message-headers. a message-body must not be included in
    a request if the specification of the request method (section 5.1.1)
    does not allow sending an entity-body in requests. a server should
    read and forward a message-body on any request; if the request method
    does not include defined semantics for an entity-body, then the
    message-body should be ignored when handling the request.

    for response messages, whether or not a message-body is included with
    a message is dependent on both the request method and the response
    status code (section 6.1.1). all responses to the head request method
    must not include a message-body, even though the presence of entity-
    header fields might lead one to believe they do. all 1xx
    (informational), 204 (no content), and 304 (not modified) responses
    must not include a message-body. all other responses do include a
    message-body, although it may be of zero length.

    4.4 message length

    the transfer-length of a message is the length of the message-body as
    it appears in the message; that is, after any transfer-codings have
    been applied. when a message-body is included with a message, the
    transfer-length of that body is determined by one of the following
    (in order of precedence):

    1.any response message which "must not" include a message-body (such
    as the 1xx, 204, and 304 responses and any response to a head
    request) is always terminated by the first empty line after the
    header fields, regardless of the entity-header fields present in
    the message.

    2.if a transfer-encoding header field (section 14.41) is present and
    has any value other than "identity", then the transfer-length is
    defined by use of the "chunked" transfer-coding (section 3.6),
    unless the message is terminated by closing the connection.

    3.if a content-length header field (section 14.13) is present, its
    decimal value in octets represents both the entity-length and the
    transfer-length. the content-length header field must not be sent
    if these two lengths are different (i.e., if a transfer-encoding

    fielding, et al. standards track [page 33]

    rfc 2616 http/1.1 june 1999

    header field is present). if a message is received with both a
    transfer-encoding header field and a content-length header field,
    the latter must be ignored.

    4.if the message uses the media type "multipart/byteranges", and the
    ransfer-length is not otherwise specified, then this self-
    elimiting media type defines the transfer-length. this media type
    ust not be used unless the sender knows that the recipient can arse
    it; the presence in a request of a range header with ultiple byte-
    range specifiers from a 1.1 client implies that the lient can parse
    multipart/byteranges responses.

    a range header might be forwarded by a 1.0 proxy that does not
    understand multipart/byteranges; in this case the server must
    delimit the message using methods defined in items 1,3 or 5 of
    this section.

    5.by the server closing the connection. (closing the connection
    cannot be used to indicate the end of a request body, since that
    would leave no possibility for the server to send back a response.)

    for compatibility with http/1.0 applications, http/1.1 requests
    containing a message-body must include a valid content-length header
    field unless the server is known to be http/1.1 compliant. if a
    request contains a message-body and a content-length is not given,
    the server should respond with 400 (bad request) if it cannot
    determine the length of the message, or with 411 (length required) if
    it wishes to insist on receiving a valid content-length.

    all http/1.1 applications that receive entities must accept the
    "chunked" transfer-coding (section 3.6), thus allowing this mechanism
    to be used for messages when the message length cannot be determined
    in advance.

    messages must not include both a content-length header field and a
    non-identity transfer-coding. if the message does include a non-
    identity transfer-coding, the content-length must be ignored.

    when a content-length is given in a message where a message-body is
    allowed, its field value must exactly match the number of octets in
    the message-body. http/1.1 user agents must notify the user when an
    invalid length is received and detected.

    4.5 general header fields

    there are a few header fields which have general applicability for
    both request and response messages, but which do not apply to the
    entity being transferred. these header fields apply only to the

    fielding, et al. standards track [page 34]

    rfc 2616 http/1.1 june 1999

    message being transmitted.

    general-header = cache-control ; section 14.9
    | connection ; section 14.10
    | date ; section 14.18
    | pragma ; section 14.32
    | trailer ; section 14.40
    | transfer-encoding ; section 14.41
    | upgrade ; section 14.42
    | via ; section 14.45
    | warning ; section 14.46

    general-header field names can be extended reliably only in
    combination with a change in the protocol version. however, new or
    experimental header fields may be given the semantics of general
    header fields if all parties in the communication recognize them to
    be general-header fields. unrecognized header fields are treated as
    entity-header fields.

    5 request

    a request message from a client to a server includes, within the
    first line of that message, the method to be applied to the resource,
    the identifier of the resource, and the protocol version in use.

    request = request-line ; section 5.1
    *(( general-header ; section 4.5
    | request-header ; section 5.3
    | entity-header ) crlf) ; section 7.1
    crlf
    [ message-body ] ; section 4.3

    5.1 request-line

    the request-line begins with a method token, followed by the
    request-uri and the protocol version, and ending with crlf. the
    elements are separated by sp characters. no cr or lf is allowed
    except in the final crlf sequence.

    request-line = method sp request-uri sp http-version crlf

    fielding, et al. standards track [page 35]

    rfc 2616 http/1.1 june 1999

    5.1.1 method

    the method token indicates the method to be performed on the
    resource identified by the request-uri. the method is case-sensitive.

    method = "options" ; section 9.2
    | "get" ; section 9.3
    | "head" ; section 9.4
    | "post" ; section 9.5
    | "put" ; section 9.6
    | "delete" ; section 9.7
    | "trace" ; section 9.8
    | "connect" ; section 9.9
    | extension-method
    extension-method = token

    the list of methods allowed by a resource can be specified in an
    allow header field (section 14.7). the return code of the response
    always notifies the client whether a method is currently allowed on a
    resource, since the set of allowed methods can change dynamically. an
    origin server should return the status code 405 (method not allowed)
    if the method is known by the origin server but not allowed for the
    requested resource, and 501 (not implemented) if the method is
    unrecognized or not implemented by the origin server. the methods get
    and head must be supported by all general-purpose servers. all other
    methods are optional; however, if the above methods are implemented,
    they must be implemented with the same semantics as those specified
    in section 9.

    5.1.2 request-uri

    the request-uri is a uniform resource identifier (section 3.2) and
    identifies the resource upon which to apply the request.

    request-uri = "*" | absoluteuri | abs_path | authority

    the four options for request-uri are dependent on the nature of the
    request. the asterisk "*" means that the request does not apply to a
    particular resource, but to the server itself, and is only allowed
    when the method used does not necessarily apply to a resource. one
    example would be

    options * http/1.1

    the absoluteuri form is required when the request is being made to a
    proxy. the proxy is requested to forward the request or service it
    from a valid cache, and return the response. note that the proxy may
    forward the request on to another proxy or directly to the server

    fielding, et al. standards track [page 36]

    rfc 2616 http/1.1 june 1999

    specified by the absoluteuri. in order to avoid request loops, a
    proxy must be able to recognize all of its server names, including
    any aliases, local variations, and the numeric ip address. an example
    request-line would be:

    get http://www.w3.org/pub/www/theproject.html http/1.1

    to allow for transition to absoluteuris in all requests in future
    versions of http, all http/1.1 servers must accept the absoluteuri
    form in requests, even though http/1.1 clients will only generate
    them in requests to proxies.

    the authority form is only used by the connect method (section 9.9).

    the most common form of request-uri is that used to identify a
    resource on an origin server or gateway. in this case the absolute
    path of the uri must be transmitted (see section 3.2.1, abs_path) as
    the request-uri, and the network location of the uri (authority) must
    be transmitted in a host header field. for example, a client wishing
    to retrieve the resource above directly from the origin server would
    create a tcp connection to port 80 of the host "www.w3.org" and send
    the lines:

    get /pub/www/theproject.html http/1.1
    host: www.w3.org

    followed by the remainder of the request. note that the absolute path
    cannot be empty; if none is present in the original uri, it must be
    given as "/" (the server root).

    the request-uri is transmitted in the format specified in section
    3.2.1. if the request-uri is encoded using the "% hex hex" encoding
    [42], the origin server must decode the request-uri in order to
    properly interpret the request. servers should respond to invalid
    request-uris with an appropriate status code.

    a transparent proxy must not rewrite the "abs_path" part of the
    received request-uri when forwarding it to the next inbound server,
    except as noted above to replace a null abs_path with "/".

    note: the "no rewrite" rule prevents the proxy from changing the
    meaning of the request when the origin server is improperly using
    a non-reserved uri character for a reserved purpose. implementors
    should be aware that some pre-http/1.1 proxies have been known to
    rewrite the request-uri.

    fielding, et al. standards track [page 37]

    rfc 2616 http/1.1 june 1999

    5.2 the resource identified by a request

    the exact resource identified by an internet request is determined by
    examining both the request-uri and the host header field.

    an origin server that does not allow resources to differ by the
    requested host may ignore the host header field value when
    determining the resource identified by an http/1.1 request. (but see
    section 19.6.1.1 for other requirements on host support in http/1.1.)

    an origin server that does differentiate resources based on the host
    requested (sometimes referred to as virtual hosts or vanity host
    names) must use the following rules for determining the requested
    resource on an http/1.1 request:

    1. if request-uri is an absoluteuri, the host is part of the
    request-uri. any host header field value in the request must be
    ignored.

    2. if the request-uri is not an absoluteuri, and the request includes
    a host header field, the host is determined by the host header
    field value.

    3. if the host as determined by rule 1 or 2 is not a valid host on
    the server, the response must be a 400 (bad request) error message.

    recipients of an http/1.0 request that lacks a host header field may
    attempt to use heuristics (e.g., examination of the uri path for
    something unique to a particular host) in order to determine what
    exact resource is being requested.

    5.3 request header fields

    the request-header fields allow the client to pass additional
    information about the request, and about the client itself, to the
    server. these fields act as request modifiers, with semantics
    equivalent to the parameters on a programming language method
    invocation.

    request-header = accept ; section 14.1
    | accept-charset ; section 14.2
    | accept-encoding ; section 14.3
    | accept-language ; section 14.4
    | authorization ; section 14.8
    | expect ; section 14.20
    | from ; section 14.22
    | host ; section 14.23
    | if-match ; section 14.24

    fielding, et al. standards track [page 38]

    rfc 2616 http/1.1 june 1999

    | if-modified-since ; section 14.25
    | if-none-match ; section 14.26
    | if-range ; section 14.27
    | if-unmodified-since ; section 14.28
    | max-forwards ; section 14.31
    | proxy-authorization ; section 14.34
    | range ; section 14.35
    | referer ; section 14.36
    | te ; section 14.39
    | user-agent ; section 14.43

    request-header field names can be extended reliably only in
    combination with a change in the protocol version. however, new or
    experimental header fields may be given the semantics of request-
    header fields if all parties in the communication recognize them to
    be request-header fields. unrecognized header fields are treated as
    entity-header fields.

    6 response

    after receiving and interpreting a request message, a server responds
    with an http response message.

    response = status-line ; section 6.1
    *(( general-header ; section 4.5
    | response-header ; section 6.2
    | entity-header ) crlf) ; section 7.1
    crlf
    [ message-body ] ; section 7.2

    6.1 status-line

    the first line of a response message is the status-line, consisting
    of the protocol version followed by a numeric status code and its
    associated textual phrase, with each element separated by sp
    characters. no cr or lf is allowed except in the final crlf sequence.

    status-line = http-version sp status-code sp reason-phrase crlf

    6.1.1 status code and reason phrase

    the status-code element is a 3-digit integer result code of the
    attempt to understand and satisfy the request. these codes are fully
    defined in section 10. the reason-phrase is intended to give a short
    textual description of the status-code. the status-code is intended
    for use by automata and the reason-phrase is intended for the human
    user. the client is not required to examine or display the reason-
    phrase.

    fielding, et al. standards track [page 39]

    rfc 2616 http/1.1 june 1999

    the first digit of the status-code defines the class of response. the
    last two digits do not have any categorization role. there are 5
    values for the first digit:

    - 1xx: informational - request received, continuing process

    - 2xx: success - the action was successfully received,
    understood, and accepted

    - 3xx: redirection - further action must be taken in order to
    complete the request

    - 4xx: client error - the request contains bad syntax or cannot
    be fulfilled

    - 5xx: server error - the server failed to fulfill an apparently
    valid request

    the individual values of the numeric status codes defined for
    http/1.1, and an example set of corresponding reason-phrase's, are
    presented below. the reason phrases listed here are only
    recommendations -- they may be replaced by local equivalents without
    affecting the protocol.

    status-code =
    "100" ; section 10.1.1: continue
    | "101" ; section 10.1.2: switching protocols
    | "200" ; section 10.2.1: ok
    | "201" ; section 10.2.2: created
    | "202" ; section 10.2.3: accepted
    | "203" ; section 10.2.4: non-authoritative information
    | "204" ; section 10.2.5: no content
    | "205" ; section 10.2.6: reset content
    | "206" ; section 10.2.7: partial content
    | "300" ; section 10.3.1: multiple choices
    | "301" ; section 10.3.2: moved permanently
    | "302" ; section 10.3.3: found
    | "303" ; section 10.3.4: see other
    | "304" ; section 10.3.5: not modified
    | "305" ; section 10.3.6: use proxy
    | "307" ; section 10.3.8: temporary redirect
    | "400" ; section 10.4.1: bad request
    | "401" ; section 10.4.2: unauthorized
    | "402" ; section 10.4.3: payment required
    | "403" ; section 10.4.4: forbidden
    | "404" ; section 10.4.5: not found
    | "405" ; section 10.4.6: method not allowed
    | "406" ; section 10.4.7: not acceptable

    fielding, et al. standards track [page 40]

    rfc 2616 http/1.1 june 1999

    | "407" ; section 10.4.8: proxy authentication required
    | "408" ; section 10.4.9: request time-out
    | "409" ; section 10.4.10: conflict
    | "410" ; section 10.4.11: gone
    | "411" ; section 10.4.12: length required
    | "412" ; section 10.4.13: precondition failed
    | "413" ; section 10.4.14: request entity too large
    | "414" ; section 10.4.15: request-uri too large
    | "415" ; section 10.4.16: unsupported media type
    | "416" ; section 10.4.17: requested range not satisfiable
    | "417" ; section 10.4.18: expectation failed
    | "500" ; section 10.5.1: internal server error
    | "501" ; section 10.5.2: not implemented
    | "502" ; section 10.5.3: bad gateway
    | "503" ; section 10.5.4: service unavailable
    | "504" ; section 10.5.5: gateway time-out
    | "505" ; section 10.5.6: http version not supported
    | extension-code

    extension-code = 3digit
    reason-phrase = *<text, excluding cr, lf>

    http status codes are extensible. http applications are not required
    to understand the meaning of all registered status codes, though such
    understanding is obviously desirable. however, applications must
    understand the class of any status code, as indicated by the first
    digit, and treat any unrecognized response as being equivalent to the
    x00 status code of that class, with the exception that an
    unrecognized response must not be cached. for example, if an
    unrecognized status code of 431 is received by the client, it can
    safely assume that there was something wrong with its request and
    treat the response as if it had received a 400 status code. in such
    cases, user agents should present to the user the entity returned
    with the response, since that entity is likely to include human-
    readable information which will explain the unusual status.

    6.2 response header fields

    the response-header fields allow the server to pass additional
    information about the response which cannot be placed in the status-
    line. these header fields give information about the server and about
    further access to the resource identified by the request-uri.

    response-header = accept-ranges ; section 14.5
    | age ; section 14.6
    | etag ; section 14.19
    | location ; section 14.30
    | proxy-authenticate ; section 14.33
  • fielding, et al. standards track [page 41]

    rfc 2616 http/1.1 june 1999

    | retry-after ; section 14.37
    | server ; section 14.38
    | vary ; section 14.44
    | www-authenticate ; section 14.47

    response-header field names can be extended reliably only in
    combination with a change in the protocol version. however, new or
    experimental header fields may be given the semantics of response-
    header fields if all parties in the communication recognize them to
    be response-header fields. unrecognized header fields are treated as
    entity-header fields.

    7 entity

    request and response messages may transfer an entity if not otherwise
    restricted by the request method or response status code. an entity
    consists of entity-header fields and an entity-body, although some
    responses will only include the entity-headers.

    in this section, both sender and recipient refer to either the client
    or the server, depending on who sends and who receives the entity.

    7.1 entity header fields

    entity-header fields define metainformation about the entity-body or,
    if no body is present, about the resource identified by the request.
    some of this metainformation is optional; some might be required by
    portions of this specification.

    entity-header = allow ; section 14.7
    | content-encoding ; section 14.11
    | content-language ; section 14.12
    | content-length ; section 14.13
    | content-location ; section 14.14
    | content-md5 ; section 14.15
    | content-range ; section 14.16
    | content-type ; section 14.17
    | expires ; section 14.21
    | last-modified ; section 14.29
    | extension-header

    extension-header = message-header

    the extension-header mechanism allows additional entity-header fields
    to be defined without changing the protocol, but these fields cannot
    be assumed to be recognizable by the recipient. unrecognized header
    fields should be ignored by the recipient and must be forwarded by
    transparent proxies.

    fielding, et al. standards track [page 42]

    rfc 2616 http/1.1 june 1999

    7.2 entity body

    the entity-body (if any) sent with an http request or response is in
    a format and encoding defined by the entity-header fields.

    entity-body = *octet

    an entity-body is only present in a message when a message-body is
    present, as described in section 4.3. the entity-body is obtained
    from the message-body by decoding any transfer-encoding that might
    have been applied to ensure safe and proper transfer of the message.

    7.2.1 type

    when an entity-body is included with a message, the data type of that
    body is determined via the header fields content-type and content-
    encoding. these define a two-layer, ordered encoding model:

    entity-body := content-encoding( content-type( data ) )

    content-type specifies the media type of the underlying data.
    content-encoding may be used to indicate any additional content
    codings applied to the data, usually for the purpose of data
    compression, that are a property of the requested resource. there is
    no default encoding.

    any http/1.1 message containing an entity-body should include a
    content-type header field defining the media type of that body. if
    and only if the media type is not given by a content-type field, the
    recipient may attempt to guess the media type via inspection of its
    content and/or the name extension(s) of the uri used to identify the
    resource. if the media type remains unknown, the recipient should
    treat it as type "application/octet-stream".

    7.2.2 entity length

    the entity-length of a message is the length of the message-body
    before any transfer-codings have been applied. section 4.4 defines
    how the transfer-length of a message-body is determined.

    fielding, et al. standards track [page 43]

    rfc 2616 http/1.1 june 1999

    8 connections

    8.1 persistent connections

    8.1.1 purpose

    prior to persistent connections, a separate tcp connection was
    established to fetch each url, increasing the load on http servers
    and causing congestion on the internet. the use of inline images and
    other associated data often require a client to make multiple
    requests of the same server in a short amount of time. analysis of
    these performance problems and results from a prototype
    implementation are available [26] [30]. implementation experience and
    measurements of actual http/1.1 (rfc 2068) implementations show good
    results [39]. alternatives have also been explored, for example,
    t/tcp [27].

    persistent http connections have a number of advantages:

    - by opening and closing fewer tcp connections, cpu time is saved
    in routers and hosts (clients, servers, proxies, gateways,
    tunnels, or caches), and memory used for tcp protocol control
    blocks can be saved in hosts.

    - http requests and responses can be pipelined on a connection.
    pipelining allows a client to make multiple requests without
    waiting for each response, allowing a single tcp connection to
    be used much more efficiently, with much lower elapsed time.

    - network congestion is reduced by reducing the number of packets
    caused by tcp opens, and by allowing tcp sufficient time to
    determine the congestion state of the network.

    - latency on subsequent requests is reduced since there is no time
    spent in tcp's connection opening handshake.

    - http can evolve more gracefully, since errors can be reported
    without the penalty of closing the tcp connection. clients using
    future versions of http might optimistically try a new feature,
    but if communicating with an older server, retry with old
    semantics after an error is reported.

    http implementations should implement persistent connections.

    fielding, et al. standards track [page 44]

    rfc 2616 http/1.1 june 1999

    8.1.2 overall operation

    a significant difference between http/1.1 and earlier versions of
    http is that persistent connections are the default behavior of any
    http connection. that is, unless otherwise indicated, the client
    should assume that the server will maintain a persistent connection,
    even after error responses from the server.

    persistent connections provide a mechanism by which a client and a
    server can signal the close of a tcp connection. this signaling takes
    place using the connection header field (section 14.10). once a close
    has been signaled, the client must not send any more requests on that
    connection.

    8.1.2.1 negotiation

    an http/1.1 server may assume that a http/1.1 client intends to
    maintain a persistent connection unless a connection header including
    the connection-token "close" was sent in the request. if the server
    chooses to close the connection immediately after sending the
    response, it should send a connection header including the
    connection-token close.

    an http/1.1 client may expect a connection to remain open, but would
    decide to keep it open based on whether the response from a server
    contains a connection header with the connection-token close. in case
    the client does not want to maintain a connection for more than that
    request, it should send a connection header including the
    connection-token close.

    if either the client or the server sends the close token in the
    connection header, that request becomes the last one for the
    connection.

    clients and servers should not assume that a persistent connection is
    maintained for http versions less than 1.1 unless it is explicitly
    signaled. see section 19.6.2 for more information on backward
    compatibility with http/1.0 clients.

    in order to remain persistent, all messages on the connection must
    have a self-defined message length (i.e., one not defined by closure
    of the connection), as described in section 4.4.

    fielding, et al. standards track [page 45]

    rfc 2616 http/1.1 june 1999

    8.1.2.2 pipelining

    a client that supports persistent connections may "pipeline" its
    requests (i.e., send multiple requests without waiting for each
    response). a server must send its responses to those requests in the
    same order that the requests were received.

    clients which assume persistent connections and pipeline immediately
    after connection establishment should be prepared to retry their
    connection if the first pipelined attempt fails. if a client does
    such a retry, it must not pipeline before it knows the connection is
    persistent. clients must also be prepared to resend their requests if
    the server closes the connection before sending all of the
    corresponding responses.

    clients should not pipeline requests using non-idempotent methods or
    non-idempotent sequences of methods (see section 9.1.2). otherwise, a
    premature termination of the transport connection could lead to
    indeterminate results. a client wishing to send a non-idempotent
    request should wait to send that request until it has received the
    response status for the previous request.

    8.1.3 proxy servers

    it is especially important that proxies correctly implement the
    properties of the connection header field as specified in section
    14.10.

    the proxy server must signal persistent connections separately with
    its clients and the origin servers (or other proxy servers) that it
    connects to. each persistent connection applies to only one transport
    link.

    a proxy server must not establish a http/1.1 persistent connection
    with an http/1.0 client (but see rfc 2068 [33] for information and
    discussion of the problems with the keep-alive header implemented by
    many http/1.0 clients).

    8.1.4 practical considerations

    servers will usually have some time-out value beyond which they will
    no longer maintain an inactive connection. proxy servers might make
    this a higher value since it is likely that the client will be making
    more connections through the same server. the use of persistent
    connections places no requirements on the length (or existence) of
    this time-out for either the client or the server.

    fielding, et al. standards track [page 46]

    rfc 2616 http/1.1 june 1999

    when a client or server wishes to time-out it should issue a graceful
    close on the transport connection. clients and servers should both
    constantly watch for the other side of the transport close, and
    respond to it as appropriate. if a client or server does not detect
    the other side's close promptly it could cause unnecessary resource
    drain on the network.

    a client, server, or proxy may close the transport connection at any
    time. for example, a client might have started to send a new request
    at the same time that the server has decided to close the "idle"
    connection. from the server's point of view, the connection is being
    closed while it was idle, but from the client's point of view, a
    request is in progress.

    this means that clients, servers, and proxies must be able to recover
    from asynchronous close events. client software should reopen the
    transport connection and retransmit the aborted sequence of requests
    without user interaction so long as the request sequence is
    idempotent (see section 9.1.2). non-idempotent methods or sequences
    must not be automatically retried, although user agents may offer a
    human operator the choice of retrying the request(s). confirmation by
    user-agent software with semantic understanding of the application
    may substitute for user confirmation. the automatic retry should not
    be repeated if the second sequence of requests fails.

    servers should always respond to at least one request per connection,
    if at all possible. servers should not close a connection in the
    middle of transmitting a response, unless a network or client failure
    is suspected.

    clients that use persistent connections should limit the number of
    simultaneous connections that they maintain to a given server. a
    single-user client should not maintain more than 2 connections with
    any server or proxy. a proxy should use up to 2*n connections to
    another server or proxy, where n is the number of simultaneously
    active users. these guidelines are intended to improve http response
    times and avoid congestion.

    8.2 message transmission requirements

    8.2.1 persistent connections and flow control

    http/1.1 servers should maintain persistent connections and use tcp's
    flow control mechanisms to resolve temporary overloads, rather than
    terminating connections with the expectation that clients will retry.
    the latter technique can exacerbate network congestion.

    fielding, et al. standards track [page 47]

    rfc 2616 http/1.1 june 1999

    8.2.2 monitoring connections for error status messages

    an http/1.1 (or later) client sending a message-body should monitor
    the network connection for an error status while it is transmitting
    the request. if the client sees an error status, it should
    immediately cease transmitting the body. if the body is being sent
    using a "chunked" encoding (section 3.6), a zero length chunk and
    empty trailer may be used to prematurely mark the end of the message.
    if the body was preceded by a content-length header, the client must
    close the connection.

    8.2.3 use of the 100 (continue) status

    the purpose of the 100 (continue) status (see section 10.1.1) is to
    allow a client that is sending a request message with a request body
    to determine if the origin server is willing to accept the request
    (based on the request headers) before the client sends the request
    body. in some cases, it might either be inappropriate or highly
    inefficient for the client to send the body if the server will reject
    the message without looking at the body.

    requirements for http/1.1 clients:

    - if a client will wait for a 100 (continue) response before
    sending the request body, it must send an expect request-header
    field (section 14.20) with the "100-continue" expectation.

    - a client must not send an expect request-header field (section
    14.20) with the "100-continue" expectation if it does not intend
    to send a request body.

    because of the presence of older implementations, the protocol allows
    ambiguous situations in which a client may send "expect: 100-
    continue" without receiving either a 417 (expectation failed) status
    or a 100 (continue) status. therefore, when a client sends this
    header field to an origin server (possibly via a proxy) from which it
    has never seen a 100 (continue) status, the client should not wait
    for an indefinite period before sending the request body.

    requirements for http/1.1 origin servers:

    - upon receiving a request which includes an expect request-header
    field with the "100-continue" expectation, an origin server must
    either respond with 100 (continue) status and continue to read
    from the input stream, or respond with a final status code. the
    origin server must not wait for the request body before sending
    the 100 (continue) response. if it responds with a final status
    code, it may close the transport connection or it may continue

    fielding, et al. standards track [page 48]

    rfc 2616 http/1.1 june 1999

    to read and discard the rest of the request. it must not
    perform the requested method if it returns a final status code.

    - an origin server should not send a 100 (continue) response if
    the request message does not include an expect request-header
    field with the "100-continue" expectation, and must not send a
    100 (continue) response if such a request comes from an http/1.0
    (or earlier) client. there is an exception to this rule: for
    compatibility with rfc 2068, a server may send a 100 (continue)
    status in response to an http/1.1 put or post request that does
    not include an expect request-header field with the "100-
    continue" expectation. this exception, the purpose of which is
    to minimize any client processing delays associated with an
    undeclared wait for 100 (continue) status, applies only to
    http/1.1 requests, and not to requests with any other http-
    version value.

    - an origin server may omit a 100 (continue) response if it has
    already received some or all of the request body for the
    corresponding request.

    - an origin server that sends a 100 (continue) response must
    ultimately send a final status code, once the request body is
    received and processed, unless it terminates the transport
    connection prematurely.

    - if an origin server receives a request that does not include an
    expect request-header field with the "100-continue" expectation,
    the request includes a request body, and the server responds
    with a final status code before reading the entire request body
    from the transport connection, then the server should not close
    the transport connection until it has read the entire request,
    or until the client closes the connection. otherwise, the client
    might not reliably receive the response message. however, this
    requirement is not be construed as preventing a server from
    defending itself against denial-of-service attacks, or from
    badly broken client implementations.

    requirements for http/1.1 proxies:

    - if a proxy receives a request that includes an expect request-
    header field with the "100-continue" expectation, and the proxy
    either knows that the next-hop server complies with http/1.1 or
    higher, or does not know the http version of the next-hop
    server, it must forward the request, including the expect header
    field.

    fielding, et al. standards track [page 49]

    rfc 2616 http/1.1 june 1999

    - if the proxy knows that the version of the next-hop server is
    http/1.0 or lower, it must not forward the request, and it must
    respond with a 417 (expectation failed) status.

    - proxies should maintain a cache recording the http version
    numbers received from recently-referenced next-hop servers.

    - a proxy must not forward a 100 (continue) response if the
    request message was received from an http/1.0 (or earlier)
    client and did not include an expect request-header field with
    the "100-continue" expectation. this requirement overrides the
    general rule for forwarding of 1xx responses (see section 10.1).

    8.2.4 client behavior if server prematurely closes connection

    if an http/1.1 client sends a request which includes a request body,
    but which does not include an expect request-header field with the
    "100-continue" expectation, and if the client is not directly
    connected to an http/1.1 origin server, and if the client sees the
    connection close before receiving any status from the server, the
    client should retry the request. if the client does retry this
    request, it may use the following "binary exponential backoff"
    algorithm to be assured of obtaining a reliable response:

    1. initiate a new connection to the server

    2. transmit the request-headers

    3. initialize a variable r to the estimated round-trip time to the
    server (e.g., based on the time it took to establish the
    connection), or to a constant value of 5 seconds if the round-
    trip time is not available.

    4. compute t = r * (2**n), where n is the number of previous
    retries of this request.

    5. wait either for an error response from the server, or for t
    seconds (whichever comes first)

    6. if no error response is received, after t seconds transmit the
    body of the request.

    7. if client sees that the connection is closed prematurely,
    repeat from step 1 until the request is accepted, an error
    response is received, or the user becomes impatient and
    terminates the retry process.

    fielding, et al. standards track [page 50]

    rfc 2616 http/1.1 june 1999

    if at any point an error status is received, the client

    - should not continue and

    - should close the connection if it has not completed sending the
    request message.

    9 method definitions

    the set of common methods for http/1.1 is defined below. although
    this set can be expanded, additional methods cannot be assumed to
    share the same semantics for separately extended clients and servers.

    the host request-header field (section 14.23) must accompany all
    http/1.1 requests.

    9.1 safe and idempotent methods

    9.1.1 safe methods

    implementors should be aware that the software represents the user in
    their interactions over the internet, and should be careful to allow
    the user to be aware of any actions they might take which may have an
    unexpected significance to themselves or others.

    in particular, the convention has been established that the get and
    head methods should not have the significance of taking an action
    other than retrieval. these methods ought to be considered "safe".
    this allows user agents to represent other methods, such as post, put
    and delete, in a special way, so that the user is made aware of the
    fact that a possibly unsafe action is being requested.

    naturally, it is not possible to ensure that the server does not
    generate side-effects as a result of performing a get request; in
    fact, some dynamic resources consider that a feature. the important
    distinction here is that the user did not request the side-effects,
    so therefore cannot be held accountable for them.

    9.1.2 idempotent methods

    methods can also have the property of "idempotence" in that (aside
    from error or expiration issues) the side-effects of n > 0 identical
    requests is the same as for a single request. the methods get, head,
    put and delete share this property. also, the methods options and
    trace should not have side effects, and so are inherently idempotent.
  • fielding, et al. standards track [page 51]

    rfc 2616 http/1.1 june 1999

    however, it is possible that a sequence of several requests is non-
    idempotent, even if all of the methods executed in that sequence are
    idempotent. (a sequence is idempotent if a single execution of the
    entire sequence always yields a result that is not changed by a
    reexecution of all, or part, of that sequence.) for example, a
    sequence is non-idempotent if its result depends on a value that is
    later modified in the same sequence.

    a sequence that never has side effects is idempotent, by definition
    (provided that no concurrent operations are being executed on the
    same set of resources).

    9.2 options

    the options method represents a request for information about the
    communication options available on the request/response chain
    identified by the request-uri. this method allows the client to
    determine the options and/or requirements associated with a resource,
    or the capabilities of a server, without implying a resource action
    or initiating a resource retrieval.

    responses to this method are not cacheable.

    if the options request includes an entity-body (as indicated by the
    presence of content-length or transfer-encoding), then the media type
    must be indicated by a content-type field. although this
    specification does not define any use for such a body, future
    extensions to http might use the options body to make more detailed
    queries on the server. a server that does not support such an
    extension may discard the request body.

    if the request-uri is an asterisk ("*"), the options request is
    intended to apply to the server in general rather than to a specific
    resource. since a server's communication options typically depend on
    the resource, the "*" request is only useful as a "ping" or "no-op"
    type of method; it does nothing beyond allowing the client to test
    the capabilities of the server. for example, this can be used to test
    a proxy for http/1.1 compliance (or lack thereof).

    if the request-uri is not an asterisk, the options request applies
    only to the options that are available when communicating with that
    resource.

    a 200 response should include any header fields that indicate
    optional features implemented by the server and applicable to that
    resource (e.g., allow), possibly including extensions not defined by
    this specification. the response body, if any, should also include
    information about the communication options. the format for such a

    fielding, et al. standards track [page 52]

    rfc 2616 http/1.1 june 1999

    body is not defined by this specification, but might be defined by
    future extensions to http. content negotiation may be used to select
    the appropriate response format. if no response body is included, the
    response must include a content-length field with a field-value of
    "0".

    the max-forwards request-header field may be used to target a
    specific proxy in the request chain. when a proxy receives an options
    request on an absoluteuri for which request forwarding is permitted,
    the proxy must check for a max-forwards field. if the max-forwards
    field-value is zero ("0"), the proxy must not forward the message;
    instead, the proxy should respond with its own communication options.
    if the max-forwards field-value is an integer greater than zero, the
    proxy must decrement the field-value when it forwards the request. if
    no max-forwards field is present in the request, then the forwarded
    request must not include a max-forwards field.

    9.3 get

    the get method means retrieve whatever information (in the form of an
    entity) is identified by the request-uri. if the request-uri refers
    to a data-producing process, it is the produced data which shall be
    returned as the entity in the response and not the source text of the
    process, unless that text happens to be the output of the process.

    the semantics of the get method change to a "conditional get" if the
    request message includes an if-modified-since, if-unmodified-since,
    if-match, if-none-match, or if-range header field. a conditional get
    method requests that the entity be transferred only under the
    circumstances described by the conditional header field(s). the
    conditional get method is intended to reduce unnecessary network
    usage by allowing cached entities to be refreshed without requiring
    multiple requests or transferring data already held by the client.

    the semantics of the get method change to a "partial get" if the
    request message includes a range header field. a partial get requests
    that only part of the entity be transferred, as described in section
    14.35. the partial get method is intended to reduce unnecessary
    network usage by allowing partially-retrieved entities to be
    completed without transferring data already held by the client.

    the response to a get request is cacheable if and only if it meets
    the requirements for http caching described in section 13.

    see section 15.1.3 for security considerations when used for forms.

    fielding, et al. standards track [page 53]

    rfc 2616 http/1.1 june 1999

    9.4 head

    the head method is identical to get except that the server must not
    return a message-body in the response. the metainformation contained
    in the http headers in response to a head request should be identical
    to the information sent in response to a get request. this method can
    be used for obtaining metainformation about the entity implied by the
    request without transferring the entity-body itself. this method is
    often used for testing hypertext links for validity, accessibility,
    and recent modification.

    the response to a head request may be cacheable in the sense that the
    information contained in the response may be used to update a
    previously cached entity from that resource. if the new field values
    indicate that the cached entity differs from the current entity (as
    would be indicated by a change in content-length, content-md5, etag
    or last-modified), then the cache must treat the cache entry as
    stale.

    9.5 post

    the post method is used to request that the origin server accept the
    entity enclosed in the request as a new subordinate of the resource
    identified by the request-uri in the request-line. post is designed
    to allow a uniform method to cover the following functions:

    - annotation of existing resources;

    - posting a message to a bulletin board, newsgroup, mailing list,
    or similar group of articles;

    - providing a block of data, such as the result of submitting a
    form, to a data-handling process;

    - extending a database through an append operation.

    the actual function performed by the post method is determined by the
    server and is usually dependent on the request-uri. the posted entity
    is subordinate to that uri in the same way that a file is subordinate
    to a directory containing it, a news article is subordinate to a
    newsgroup to which it is posted, or a record is subordinate to a
    database.

    the action performed by the post method might not result in a
    resource that can be identified by a uri. in this case, either 200
    (ok) or 204 (no content) is the appropriate response status,
    depending on whether or not the response includes an entity that
    describes the result.

    fielding, et al. standards track [page 54]

    rfc 2616 http/1.1 june 1999

    if a resource has been created on the origin server, the response
    should be 201 (created) and contain an entity which describes the
    status of the request and refers to the new resource, and a location
    header (see section 14.30).

    responses to this method are not cacheable, unless the response
    includes appropriate cache-control or expires header fields. however,
    the 303 (see other) response can be used to direct the user agent to
    retrieve a cacheable resource.

    post requests must obey the message transmission requirements set out
    in section 8.2.

    see section 15.1.3 for security considerations.

    9.6 put

    the put method requests that the enclosed entity be stored under the
    supplied request-uri. if the request-uri refers to an already
    existing resource, the enclosed entity should be considered as a
    modified version of the one residing on the origin server. if the
    request-uri does not point to an existing resource, and that uri is
    capable of being defined as a new resource by the requesting user
    agent, the origin server can create the resource with that uri. if a
    new resource is created, the origin server must inform the user agent
    via the 201 (created) response. if an existing resource is modified,
    either the 200 (ok) or 204 (no content) response codes should be sent
    to indicate successful completion of the request. if the resource
    could not be created or modified with the request-uri, an appropriate
    error response should be given that reflects the nature of the
    problem. the recipient of the entity must not ignore any content-*
    (e.g. content-range) headers that it does not understand or implement
    and must return a 501 (not implemented) response in such cases.

    if the request passes through a cache and the request-uri identifies
    one or more currently cached entities, those entries should be
    treated as stale. responses to this method are not cacheable.

    the fundamental difference between the post and put requests is
    reflected in the different meaning of the request-uri. the uri in a
    post request identifies the resource that will handle the enclosed
    entity. that resource might be a data-accepting process, a gateway to
    some other protocol, or a separate entity that accepts annotations.
    in contrast, the uri in a put request identifies the entity enclosed
    with the request -- the user agent knows what uri is intended and the
    server must not attempt to apply the request to some other resource.
    if the server desires that the request be applied to a different uri,

    fielding, et al. standards track [page 55]

    rfc 2616 http/1.1 june 1999

    it must send a 301 (moved permanently) response; the user agent may
    then make its own decision regarding whether or not to redirect the
    request.

    a single resource may be identified by many different uris. for
    example, an article might have a uri for identifying "the current
    version" which is separate from the uri identifying each particular
    version. in this case, a put request on a general uri might result in
    several other uris being defined by the origin server.

    http/1.1 does not define how a put method affects the state of an
    origin server.

    put requests must obey the message transmission requirements set out
    in section 8.2.

    unless otherwise specified for a particular entity-header, the
    entity-headers in the put request should be applied to the resource
    created or modified by the put.

    9.7 delete

    the delete method requests that the origin server delete the resource
    identified by the request-uri. this method may be overridden by human
    intervention (or other means) on the origin server. the client cannot
    be guaranteed that the operation has been carried out, even if the
    status code returned from the origin server indicates that the action
    has been completed successfully. however, the server should not
    indicate success unless, at the time the response is given, it
    intends to delete the resource or move it to an inaccessible
    location.

    a successful response should be 200 (ok) if the response includes an
    entity describing the status, 202 (accepted) if the action has not
    yet been enacted, or 204 (no content) if the action has been enacted
    but the response does not include an entity.

    if the request passes through a cache and the request-uri identifies
    one or more currently cached entities, those entries should be
    treated as stale. responses to this method are not cacheable.

    9.8 trace

    the trace method is used to invoke a remote, application-layer loop-
    back of the request message. the final recipient of the request
    should reflect the message received back to the client as the
    entity-body of a 200 (ok) response. the final recipient is either the

    fielding, et al. standards track [page 56]

    rfc 2616 http/1.1 june 1999

    origin server or the first proxy or gateway to receive a max-forwards
    value of zero (0) in the request (see section 14.31). a trace request
    must not include an entity.

    trace allows the client to see what is being received at the other
    end of the request chain and use that data for testing or diagnostic
    information. the value of the via header field (section 14.45) is of
    particular interest, since it acts as a trace of the request chain.
    use of the max-forwards header field allows the client to limit the
    length of the request chain, which is useful for testing a chain of
    proxies forwarding messages in an infinite loop.

    if the request is valid, the response should contain the entire
    request message in the entity-body, with a content-type of
    "message/http". responses to this method must not be cached.

    9.9 connect

    this specification reserves the method name connect for use with a
    proxy that can dynamically switch to being a tunnel (e.g. ssl
    tunneling [44]).

    10 status code definitions

    each status-code is described below, including a description of which
    method(s) it can follow and any metainformation required in the
    response.

    10.1 informational 1xx

    this class of status code indicates a provisional response,
    consisting only of the status-line and optional headers, and is
    terminated by an empty line. there are no required headers for this
    class of status code. since http/1.0 did not define any 1xx status
    codes, servers must not send a 1xx response to an http/1.0 client
    except under experimental conditions.

    a client must be prepared to accept one or more 1xx status responses
    prior to a regular response, even if the client does not expect a 100
    (continue) status message. unexpected 1xx status responses may be
    ignored by a user agent.

    proxies must forward 1xx responses, unless the connection between the
    proxy and its client has been closed, or unless the proxy itself
    requested the generation of the 1xx response. (for example, if a

    fielding, et al. standards track [page 57]

    rfc 2616 http/1.1 june 1999

    proxy adds a "expect: 100-continue" field when it forwards a request,
    then it need not forward the corresponding 100 (continue)
    response(s).)

    10.1.1 100 continue

    the client should continue with its request. this interim response is
    used to inform the client that the initial part of the request has
    been received and has not yet been rejected by the server. the client
    should continue by sending the remainder of the request or, if the
    request has already been completed, ignore this response. the server
    must send a final response after the request has been completed. see
    section 8.2.3 for detailed discussion of the use and handling of this
    status code.

    10.1.2 101 switching protocols

    the server understands and is willing to comply with the client's
    request, via the upgrade message header field (section 14.42), for a
    change in the application protocol being used on this connection. the
    server will switch protocols to those defined by the response's
    upgrade header field immediately after the empty line which
    terminates the 101 response.

    the protocol should be switched only when it is advantageous to do
    so. for example, switching to a newer version of http is advantageous
    over older versions, and switching to a real-time, synchronous
    protocol might be advantageous when delivering resources that use
    such features.

    10.2 successful 2xx

    this class of status code indicates that the client's request was
    successfully received, understood, and accepted.

    10.2.1 200 ok

    the request has succeeded. the information returned with the response
    is dependent on the method used in the request, for example:

    get an entity corresponding to the requested resource is sent in
    the response;

    head the entity-header fields corresponding to the requested
    resource are sent in the response without any message-body;

    post an entity describing or containing the result of the action;

    fielding, et al. standards track [page 58]

    rfc 2616 http/1.1 june 1999

    trace an entity containing the request message as received by the
    end server.

    10.2.2 201 created

    the request has been fulfilled and resulted in a new resource being
    created. the newly created resource can be referenced by the uri(s)
    returned in the entity of the response, with the most specific uri
    for the resource given by a location header field. the response
    should include an entity containing a list of resource
    characteristics and location(s) from which the user or user agent can
    choose the one most appropriate. the entity format is specified by
    the media type given in the content-type header field. the origin
    server must create the resource before returning the 201 status code.
    if the action cannot be carried out immediately, the server should
    respond with 202 (accepted) response instead.

    a 201 response may contain an etag response header field indicating
    the current value of the entity tag for the requested variant just
    created, see section 14.19.

    10.2.3 202 accepted

    the request has been accepted for processing, but the processing has
    not been completed. the request might or might not eventually be
    acted upon, as it might be disallowed when processing actually takes
    place. there is no facility for re-sending a status code from an
    asynchronous operation such as this.

    the 202 response is intentionally non-committal. its purpose is to
    allow a server to accept a request for some other process (perhaps a
    batch-oriented process that is only run once per day) without
    requiring that the user agent's connection to the server persist
    until the process is completed. the entity returned with this
    response should include an indication of the request's current status
    and either a pointer to a status monitor or some estimate of when the
    user can expect the request to be fulfilled.

    10.2.4 203 non-authoritative information

    the returned metainformation in the entity-header is not the
    definitive set as available from the origin server, but is gathered
    from a local or a third-party copy. the set presented may be a subset
    or superset of the original version. for example, including local
    annotation information about the resource might result in a superset
    of the metainformation known by the origin server. use of this
    response code is not required and is only appropriate when the
    response would otherwise be 200 (ok).

    fielding, et al. standards track [page 59]

    rfc 2616 http/1.1 june 1999

    10.2.5 204 no content

    the server has fulfilled the request but does not need to return an
    entity-body, and might want to return updated metainformation. the
    response may include new or updated metainformation in the form of
    entity-headers, which if present should be associated with the
    requested variant.

    if the client is a user agent, it should not change its document view
    from that which caused the request to be sent. this response is
    primarily intended to allow input for actions to take place without
    causing a change to the user agent's active document view, although
    any new or updated metainformation should be applied to the document
    currently in the user agent's active view.

    the 204 response must not include a message-body, and thus is always
    terminated by the first empty line after the header fields.

    10.2.6 205 reset content

    the server has fulfilled the request and the user agent should reset
    the document view which caused the request to be sent. this response
    is primarily intended to allow input for actions to take place via
    user input, followed by a clearing of the form in which the input is
    given so that the user can easily initiate another input action. the
    response must not include an entity.

    10.2.7 206 partial content

    the server has fulfilled the partial get request for the resource.
    the request must have included a range header field (section 14.35)
    indicating the desired range, and may have included an if-range
    header field (section 14.27) to make the request conditional.

    the response must include the following header fields:

    - either a content-range header field (section 14.16) indicating
    the range included with this response, or a multipart/byteranges
    content-type including content-range fields for each part. if a
    content-length header field is present in the response, its
    value must match the actual number of octets transmitted in the
    message-body.

    - date

    - etag and/or content-location, if the header would have been sent
    in a 200 response to the same request

    fielding, et al. standards track [page 60]

    rfc 2616 http/1.1 june 1999

    - expires, cache-control, and/or vary, if the field-value might
    differ from that sent in any previous response for the same
    variant

    if the 206 response is the result of an if-range request that used a
    strong cache validator (see section 13.3.3), the response should not
    include other entity-headers. if the response is the result of an
    if-range request that used a weak validator, the response must not
    include other entity-headers; this prevents inconsistencies between
    cached entity-bodies and updated headers. otherwise, the response
    must include all of the entity-headers that would have been returned
    with a 200 (ok) response to the same request.

    a cache must not combine a 206 response with other previously cached
    content if the etag or last-modified headers do not match exactly,
    see 13.5.4.

    a cache that does not support the range and content-range headers
    must not cache 206 (partial) responses.

    10.3 redirection 3xx

    this class of status code indicates that further action needs to be
    taken by the user agent in order to fulfill the request. the action
    required may be carried out by the user agent without interaction
    with the user if and only if the method used in the second request is
    get or head. a client should detect infinite redirection loops, since
    such loops generate network traffic for each redirection.

    note: previous versions of this specification recommended a
    maximum of five redirections. content developers should be aware
    that there might be clients that implement such a fixed
    limitation.

    10.3.1 300 multiple choices

    the requested resource corresponds to any one of a set of
    representations, each with its own specific location, and agent-
    driven negotiation information (section 12) is being provided so that
    the user (or user agent) can select a preferred representation and
    redirect its request to that location.

    unless it was a head request, the response should include an entity
    containing a list of resource characteristics and location(s) from
    which the user or user agent can choose the one most appropriate. the
    entity format is specified by the media type given in the content-
    type header field. depending upon the format and the capabilities of
  • fielding, et al. standards track [page 61]

    rfc 2616 http/1.1 june 1999

    the user agent, selection of the most appropriate choice may be
    performed automatically. however, this specification does not define
    any standard for such automatic selection.

    if the server has a preferred choice of representation, it should
    include the specific uri for that representation in the location
    field; user agents may use the location field value for automatic
    redirection. this response is cacheable unless indicated otherwise.

    10.3.2 301 moved permanently

    the requested resource has been assigned a new permanent uri and any
    future references to this resource should use one of the returned
    uris. clients with link editing capabilities ought to automatically
    re-link references to the request-uri to one or more of the new
    references returned by the server, where possible. this response is
    cacheable unless indicated otherwise.

    the new permanent uri should be given by the location field in the
    response. unless the request method was head, the entity of the
    response should contain a short hypertext note with a hyperlink to
    the new uri(s).

    if the 301 status code is received in response to a request other
    than get or head, the user agent must not automatically redirect the
    request unless it can be confirmed by the user, since this might
    change the conditions under which the request was issued.

    note: when automatically redirecting a post request after
    receiving a 301 status code, some existing http/1.0 user agents
    will erroneously change it into a get request.

    10.3.3 302 found

    the requested resource resides temporarily under a different uri.
    since the redirection might be altered on occasion, the client should
    continue to use the request-uri for future requests. this response
    is only cacheable if indicated by a cache-control or expires header
    field.

    the temporary uri should be given by the location field in the
    response. unless the request method was head, the entity of the
    response should contain a short hypertext note with a hyperlink to
    the new uri(s).

    fielding, et al. standards track [page 62]

    rfc 2616 http/1.1 june 1999

    if the 302 status code is received in response to a request other
    than get or head, the user agent must not automatically redirect the
    request unless it can be confirmed by the user, since this might
    change the conditions under which the request was issued.

    note: rfc 1945 and rfc 2068 specify that the client is not allowed
    to change the method on the redirected request. however, most
    existing user agent implementations treat 302 as if it were a 303
    response, performing a get on the location field-value regardless
    of the original request method. the status codes 303 and 307 have
    been added for servers that wish to make unambiguously clear which
    kind of reaction is expected of the client.

    10.3.4 303 see other

    the response to the request can be found under a different uri and
    should be retrieved using a get method on that resource. this method
    exists primarily to allow the output of a post-activated script to
    redirect the user agent to a selected resource. the new uri is not a
    substitute reference for the originally requested resource. the 303
    response must not be cached, but the response to the second
    (redirected) request might be cacheable.

    the different uri should be given by the location field in the
    response. unless the request method was head, the entity of the
    response should contain a short hypertext note with a hyperlink to
    the new uri(s).

    note: many pre-http/1.1 user agents do not understand the 303
    status. when interoperability with such clients is a concern, the
    302 status code may be used instead, since most user agents react
    to a 302 response as described here for 303.

    10.3.5 304 not modified

    if the client has performed a conditional get request and access is
    allowed, but the document has not been modified, the server should
    respond with this status code. the 304 response must not contain a
    message-body, and thus is always terminated by the first empty line
    after the header fields.

    the response must include the following header fields:

    - date, unless its omission is required by section 14.18.1

    fielding, et al. standards track [page 63]

    rfc 2616 http/1.1 june 1999

    if a clockless origin server obeys these rules, and proxies and
    clients add their own date to any response received without one (as
    already specified by [rfc 2068], section 14.19), caches will operate
    correctly.

    - etag and/or content-location, if the header would have been sent
    in a 200 response to the same request

    - expires, cache-control, and/or vary, if the field-value might
    differ from that sent in any previous response for the same
    variant

    if the conditional get used a strong cache validator (see section
    13.3.3), the response should not include other entity-headers.
    otherwise (i.e., the conditional get used a weak validator), the
    response must not include other entity-headers; this prevents
    inconsistencies between cached entity-bodies and updated headers.

    if a 304 response indicates an entity not currently cached, then the
    cache must disregard the response and repeat the request without the
    conditional.

    if a cache uses a received 304 response to update a cache entry, the
    cache must update the entry to reflect any new field values given in
    the response.

    10.3.6 305 use proxy

    the requested resource must be accessed through the proxy given by
    the location field. the location field gives the uri of the proxy.
    the recipient is expected to repeat this single request via the
    proxy. 305 responses must only be generated by origin servers.

    note: rfc 2068 was not clear that 305 was intended to redirect a
    single request, and to be generated by origin servers only. not
    observing these limitations has significant security consequences.

    10.3.7 306 (unused)

    the 306 status code was used in a previous version of the
    specification, is no longer used, and the code is reserved.

    fielding, et al. standards track [page 64]

    rfc 2616 http/1.1 june 1999

    10.3.8 307 temporary redirect

    the requested resource resides temporarily under a different uri.
    since the redirection may be altered on occasion, the client should
    continue to use the request-uri for future requests. this response
    is only cacheable if indicated by a cache-control or expires header
    field.

    the temporary uri should be given by the location field in the
    response. unless the request method was head, the entity of the
    response should contain a short hypertext note with a hyperlink to
    the new uri(s) , since many pre-http/1.1 user agents do not
    understand the 307 status. therefore, the note should contain the
    information necessary for a user to repeat the original request on
    the new uri.

    if the 307 status code is received in response to a request other
    than get or head, the user agent must not automatically redirect the
    request unless it can be confirmed by the user, since this might
    change the conditions under which the request was issued.

    10.4 client error 4xx

    the 4xx class of status code is intended for cases in which the
    client seems to have erred. except when responding to a head request,
    the server should include an entity containing an explanation of the
    error situation, and whether it is a temporary or permanent
    condition. these status codes are applicable to any request method.
    user agents should display any included entity to the user.

    if the client is sending data, a server implementation using tcp
    should be careful to ensure that the client acknowledges receipt of
    the packet(s) containing the response, before the server closes the
    input connection. if the client continues sending data to the server
    after the close, the server's tcp stack will send a reset packet to
    the client, which may erase the client's unacknowledged input buffers
    before they can be read and interpreted by the http application.

    10.4.1 400 bad request

    the request could not be understood by the server due to malformed
    syntax. the client should not repeat the request without
    modifications.

    fielding, et al. standards track [page 65]

    rfc 2616 http/1.1 june 1999

    10.4.2 401 unauthorized

    the request requires user authentication. the response must include a
    www-authenticate header field (section 14.47) containing a challenge
    applicable to the requested resource. the client may repeat the
    request with a suitable authorization header field (section 14.8). if
    the request already included authorization credentials, then the 401
    response indicates that authorization has been refused for those
    credentials. if the 401 response contains the same challenge as the
    prior response, and the user agent has already attempted
    authentication at least once, then the user should be presented the
    entity that was given in the response, since that entity might
    include relevant diagnostic information. http access authentication
    is explained in "http authentication: basic and digest access
    authentication" [43].

    10.4.3 402 payment required

    this code is reserved for future use.

    10.4.4 403 forbidden

    the server understood the request, but is refusing to fulfill it.
    authorization will not help and the request should not be repeated.
    if the request method was not head and the server wishes to make
    public why the request has not been fulfilled, it should describe the
    reason for the refusal in the entity. if the server does not wish to
    make this information available to the client, the status code 404
    (not found) can be used instead.

    10.4.5 404 not found

    the server has not found anything matching the request-uri. no
    indication is given of whether the condition is temporary or
    permanent. the 410 (gone) status code should be used if the server
    knows, through some internally configurable mechanism, that an old
    resource is permanently unavailable and has no forwarding address.
    this status code is commonly used when the server does not wish to
    reveal exactly why the request has been refused, or when no other
    response is applicable.

    10.4.6 405 method not allowed

    the method specified in the request-line is not allowed for the
    resource identified by the request-uri. the response must include an
    allow header containing a list of valid methods for the requested
    resource.

    fielding, et al. standards track [page 66]

    rfc 2616 http/1.1 june 1999

    10.4.7 406 not acceptable

    the resource identified by the request is only capable of generating
    response entities which have content characteristics not acceptable
    according to the accept headers sent in the request.

    unless it was a head request, the response should include an entity
    containing a list of available entity characteristics and location(s)
    from which the user or user agent can choose the one most
    appropriate. the entity format is specified by the media type given
    in the content-type header field. depending upon the format and the
    capabilities of the user agent, selection of the most appropriate
    choice may be performed automatically. however, this specification
    does not define any standard for such automatic selection.

    note: http/1.1 servers are allowed to return responses which are
    not acceptable according to the accept headers sent in the
    request. in some cases, this may even be preferable to sending a
    406 response. user agents are encouraged to inspect the headers of
    an incoming response to determine if it is acceptable.

    if the response could be unacceptable, a user agent should
    temporarily stop receipt of more data and query the user for a
    decision on further actions.

    10.4.8 407 proxy authentication required

    this code is similar to 401 (unauthorized), but indicates that the
    client must first authenticate itself with the proxy. the proxy must
    return a proxy-authenticate header field (section 14.33) containing a
    challenge applicable to the proxy for the requested resource. the
    client may repeat the request with a suitable proxy-authorization
    header field (section 14.34). http access authentication is explained
    in "http authentication: basic and digest access authentication"
    [43].

    10.4.9 408 request timeout

    the client did not produce a request within the time that the server
    was prepared to wait. the client may repeat the request without
    modifications at any later time.

    10.4.10 409 conflict

    the request could not be completed due to a conflict with the current
    state of the resource. this code is only allowed in situations where
    it is expected that the user might be able to resolve the conflict
    and resubmit the request. the response body should include enough

    fielding, et al. standards track [page 67]

    rfc 2616 http/1.1 june 1999

    information for the user to recognize the source of the conflict.
    ideally, the response entity would include enough information for the
    user or user agent to fix the problem; however, that might not be
    possible and is not required.

    conflicts are most likely to occur in response to a put request. for
    example, if versioning were being used and the entity being put
    included changes to a resource which conflict with those made by an
    earlier (third-party) request, the server might use the 409 response
    to indicate that it can't complete the request. in this case, the
    response entity would likely contain a list of the differences
    between the two versions in a format defined by the response
    content-type.

    10.4.11 410 gone

    the requested resource is no longer available at the server and no
    forwarding address is known. this condition is expected to be
    considered permanent. clients with link editing capabilities should
    delete references to the request-uri after user approval. if the
    server does not know, or has no facility to determine, whether or not
    the condition is permanent, the status code 404 (not found) should be
    used instead. this response is cacheable unless indicated otherwise.

    the 410 response is primarily intended to assist the task of web
    maintenance by notifying the recipient that the resource is
    intentionally unavailable and that the server owners desire that
    remote links to that resource be removed. such an event is common for
    limited-time, promotional services and for resources belonging to
    individuals no longer working at the server's site. it is not
    necessary to mark all permanently unavailable resources as "gone" or
    to keep the mark for any length of time -- that is left to the
    discretion of the server owner.

    10.4.12 411 length required

    the server refuses to accept the request without a defined content-
    length. the client may repeat the request if it adds a valid
    content-length header field containing the length of the message-body
    in the request message.

    10.4.13 412 precondition failed

    the precondition given in one or more of the request-header fields
    evaluated to false when it was tested on the server. this response
    code allows the client to place preconditions on the current resource
    metainformation (header field data) and thus prevent the requested
    method from being applied to a resource other than the one intended.

    fielding, et al. standards track [page 68]

    rfc 2616 http/1.1 june 1999

    10.4.14 413 request entity too large

    the server is refusing to process a request because the request
    entity is larger than the server is willing or able to process. the
    server may close the connection to prevent the client from continuing
    the request.

    if the condition is temporary, the server should include a retry-
    after header field to indicate that it is temporary and after what
    time the client may try again.

    10.4.15 414 request-uri too long

    the server is refusing to service the request because the request-uri
    is longer than the server is willing to interpret. this rare
    condition is only likely to occur when a client has improperly
    converted a post request to a get request with long query
    information, when the client has descended into a uri "black hole" of
    redirection (e.g., a redirected uri prefix that points to a suffix of
    itself), or when the server is under attack by a client attempting to
    exploit security holes present in some servers using fixed-length
    buffers for reading or manipulating the request-uri.

    10.4.16 415 unsupported media type

    the server is refusing to service the request because the entity of
    the request is in a format not supported by the requested resource
    for the requested method.

    10.4.17 416 requested range not satisfiable

    a server should return a response with this status code if a request
    included a range request-header field (section 14.35), and none of
    the range-specifier values in this field overlap the current extent
    of the selected resource, and the request did not include an if-range
    request-header field. (for byte-ranges, this means that the first-
    byte-pos of all of the byte-range-spec values were greater than the
    current length of the selected resource.)

    when this status code is returned for a byte-range request, the
    response should include a content-range entity-header field
    specifying the current length of the selected resource (see section
    14.16). this response must not use the multipart/byteranges content-
    type.

    fielding, et al. standards track [page 69]

    rfc 2616 http/1.1 june 1999

    10.4.18 417 expectation failed

    the expectation given in an expect request-header field (see section
    14.20) could not be met by this server, or, if the server is a proxy,
    the server has unambiguous evidence that the request could not be met
    by the next-hop server.

    10.5 server error 5xx

    response status codes beginning with the digit "5" indicate cases in
    which the server is aware that it has erred or is incapable of
    performing the request. except when responding to a head request, the
    server should include an entity containing an explanation of the
    error situation, and whether it is a temporary or permanent
    condition. user agents should display any included entity to the
    user. these response codes are applicable to any request method.

    10.5.1 500 internal server error

    the server encountered an unexpected condition which prevented it
    from fulfilling the request.

    10.5.2 501 not implemented

    the server does not support the functionality required to fulfill the
    request. this is the appropriate response when the server does not
    recognize the request method and is not capable of supporting it for
    any resource.

    10.5.3 502 bad gateway

    the server, while acting as a gateway or proxy, received an invalid
    response from the upstream server it accessed in attempting to
    fulfill the request.

    10.5.4 503 service unavailable

    the server is currently unable to handle the request due to a
    temporary overloading or maintenance of the server. the implication
    is that this is a temporary condition which will be alleviated after
    some delay. if known, the length of the delay may be indicated in a
    retry-after header. if no retry-after is given, the client should
    handle the response as it would for a 500 response.

    note: the existence of the 503 status code does not imply that a
    server must use it when becoming overloaded. some servers may wish
    to simply refuse the connection.

    fielding, et al. standards track [page 70]

    rfc 2616 http/1.1 june 1999

    10.5.5 504 gateway timeout

    the server, while acting as a gateway or proxy, did not receive a
    timely response from the upstream server specified by the uri (e.g.
    http, ftp, ldap) or some other auxiliary server (e.g. dns) it needed
    to access in attempting to complete the request.

    note: note to implementors: some deployed proxies are known to
    return 400 or 500 when dns lookups time out.

    10.5.6 505 http version not supported

    the server does not support, or refuses to support, the http protocol
    version that was used in the request message. the server is
    indicating that it is unable or unwilling to complete the request
    using the same major version as the client, as described in section
    3.1, other than with this error message. the response should contain
    an entity describing why that version is not supported and what other
    protocols are supported by that server.

    11 access authentication

    http provides several optional challenge-response authentication
    mechanisms which can be used by a server to challenge a client
    request and by a client to provide authentication information. the
    general framework for access authentication, and the specification of
    "basic" and "digest" authentication, are specified in "http
    authentication: basic and digest access authentication" [43]. this
    specification adopts the definitions of "challenge" and "credentials"
    from that specification.

    12 content negotiation

    most http responses include an entity which contains information for
    interpretation by a human user. naturally, it is desirable to supply
    the user with the "best available" entity corresponding to the
    request. unfortunately for servers and caches, not all users have the
    same preferences for what is "best," and not all user agents are
    equally capable of rendering all entity types. for that reason, http
    has provisions for several mechanisms for "content negotiation" --
    the process of selecting the best representation for a given response
    when there are multiple representations available.

    note: this is not called "format negotiation" because the
    alternate representations may be of the same media type, but use
    different capabilities of that type, be in different languages,
    etc.
  • fielding, et al. standards track [page 71]

    rfc 2616 http/1.1 june 1999

    any response containing an entity-body may be subject to negotiation,
    including error responses.

    there are two kinds of content negotiation which are possible in
    http: server-driven and agent-driven negotiation. these two kinds of
    negotiation are orthogonal and thus may be used separately or in
    combination. one method of combination, referred to as transparent
    negotiation, occurs when a cache uses the agent-driven negotiation
    information provided by the origin server in order to provide
    server-driven negotiation for subsequent requests.

    12.1 server-driven negotiation

    if the selection of the best representation for a response is made by
    an algorithm located at the server, it is called server-driven
    negotiation. selection is based on the available representations of
    the response (the dimensions over which it can vary; e.g. language,
    content-coding, etc.) and the contents of particular header fields in
    the request message or on other information pertaining to the request
    (such as the network address of the client).

    server-driven negotiation is advantageous when the algorithm for
    selecting from among the available representations is difficult to
    describe to the user agent, or when the server desires to send its
    "best guess" to the client 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, the user agent may include request header fields (accept,
    accept-language, accept-encoding, etc.) which describe its
    preferences for such a response.

    server-driven negotiation has disadvantages:

    1. 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?).

    2. 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 violation of the user's privacy.

    3. it complicates the implementation of an origin server and the
    algorithms for generating responses to a request.

    fielding, et al. standards track [page 72]

    rfc 2616 http/1.1 june 1999

    4. it may limit a public cache's ability to use the same response
    for multiple user's requests.

    http/1.1 includes the following request-header fields for enabling
    server-driven negotiation through description of user agent
    capabilities and user preferences: accept (section 14.1), accept-
    charset (section 14.2), accept-encoding (section 14.3), accept-
    language (section 14.4), and user-agent (section 14.43). however, an
    origin server is not limited to these dimensions and may vary the
    response based on any aspect of the request, including information
    outside the request-header fields or within extension header fields
    not defined by this specification.

    the vary header field can be used to express the parameters the
    server uses to select a representation that is subject to server-
    driven negotiation. see section 13.6 for use of the vary header field
    by caches and section 14.44 for use of the vary header field by
    servers.

    12.2 agent-driven negotiation

    with agent-driven negotiation, selection of the best representation
    for a response is performed by the user agent after receiving an
    initial response from the origin server. selection is based on a list
    of the available representations of the response included within the
    header fields or entity-body of the initial response, with each
    representation identified by its own uri. selection from among the
    representations may be performed automatically (if the user agent is
    capable of doing so) or manually by the user selecting from a
    generated (possibly hypertext) menu.

    agent-driven 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.

    agent-driven negotiation suffers from the disadvantage of needing a
    second request to obtain the best alternate representation. this
    second request is only efficient when caching is used. in addition,
    this specification does not define any mechanism for supporting
    automatic selection, though it also does not prevent any such
    mechanism from being developed as an extension and used within
    http/1.1.

    fielding, et al. standards track [page 73]

    rfc 2616 http/1.1 june 1999

    http/1.1 defines the 300 (multiple choices) and 406 (not acceptable)
    status codes for enabling agent-driven negotiation when the server is
    unwilling or unable to provide a varying response using server-driven
    negotiation.

    12.3 transparent negotiation

    transparent negotiation is a combination of both server-driven and
    agent-driven negotiation. when a cache is supplied with a form of the
    list of available representations of the response (as in agent-driven
    negotiation) and the dimensions of variance are completely understood
    by the cache, then the cache becomes capable of performing server-
    driven negotiation on behalf of the origin server for subsequent
    requests on that resource.

    transparent negotiation has the advantage of distributing the
    negotiation work that would otherwise be required of the origin
    server and also removing the second request delay of agent-driven
    negotiation when the cache is able to correctly guess the right
    response.

    this specification does not define any mechanism for transparent
    negotiation, though it also does not prevent any such mechanism from
    being developed as an extension that could be used within http/1.1.

    13 caching in http

    http is typically used for distributed information systems, where
    performance can be improved by the use of response caches. the
    http/1.1 protocol includes a number of elements intended to make
    caching work as well as possible. because these elements are
    inextricable from other aspects of the protocol, and because they
    interact with each other, it is useful to describe the basic caching
    design of http separately from the detailed descriptions of methods,
    headers, response codes, etc.

    caching would be useless if it did not significantly improve
    performance. the goal of caching in http/1.1 is to eliminate the need
    to send requests in many cases, and to eliminate the need to send
    full responses in many other cases. the former reduces the number of
    network round-trips required for many operations; we use an
    "expiration" mechanism for this purpose (see section 13.2). the
    latter reduces network bandwidth requirements; we use a "validation"
    mechanism for this purpose (see section 13.3).

    requirements for performance, availability, and disconnected
    operation require us to be able to relax the goal of semantic
    transparency. the http/1.1 protocol allows origin servers, caches,

    fielding, et al. standards track [page 74]

    rfc 2616 http/1.1 june 1999

    and clients to explicitly reduce transparency when necessary.
    however, because non-transparent operation may confuse non-expert
    users, and might be incompatible with certain server applications
    (such as those for ordering merchandise), the protocol requires that
    transparency be relaxed

    - only by an explicit protocol-level request when relaxed by
    client or origin server

    - only with an explicit warning to the end user when relaxed by
    cache or client

    therefore, the http/1.1 protocol provides these important elements:

    1. protocol features that provide full semantic transparency when
    this is required by all parties.

    2. protocol features that allow an origin server or user agent to
    explicitly request and control non-transparent operation.

    3. protocol features that allow a cache to attach warnings to
    responses that do not preserve the requested approximation of
    semantic transparency.

    a basic principle is that it must be possible for the clients to
    detect any potential relaxation of semantic transparency.

    note: the server, cache, or client implementor might be faced with
    design decisions not explicitly discussed in this specification.
    if a decision might affect semantic transparency, the implementor
    ought to err on the side of maintaining transparency unless a
    careful and complete analysis shows significant benefits in
    breaking transparency.

    13.1.1 cache correctness

    a correct cache must respond to a request with the most up-to-date
    response held by the cache that is appropriate to the request (see
    sections 13.2.5, 13.2.6, and 13.12) which meets one of the following
    conditions:

    1. it has been checked for equivalence with what the origin server
    would have returned by revalidating the response with the
    origin server (section 13.3);

    fielding, et al. standards track [page 75]

    rfc 2616 http/1.1 june 1999

    2. it is "fresh enough" (see section 13.2). in the default case,
    this means it meets the least restrictive freshness requirement
    of the client, origin server, and cache (see section 14.9); if
    the origin server so specifies, it is the freshness requirement
    of the origin server alone.

    if a stored response is not "fresh enough" by the most
    restrictive freshness requirement of both the client and the
    origin server, in carefully considered circumstances the cache
    may still return the response with the appropriate warning
    header (see section 13.1.5 and 14.46), unless such a response
    is prohibited (e.g., by a "no-store" cache-directive, or by a
    "no-cache" cache-request-directive; see section 14.9).

    3. it is an appropriate 304 (not modified), 305 (proxy redirect),
    or error (4xx or 5xx) response message.

    if the cache can not communicate with the origin server, then a
    correct cache should respond as above if the response can be
    correctly served from the cache; if not it must return an error or
    warning indicating that there was a communication failure.

    if a cache receives a response (either an entire response, or a 304
    (not modified) response) that it would normally forward to the
    requesting client, and the received response is no longer fresh, the
    cache should forward it to the requesting client without adding a new
    warning (but without removing any existing warning headers). a cache
    should not attempt to revalidate a response simply because that
    response became stale in transit; this might lead to an infinite
    loop. a user agent that receives a stale response without a warning
    may display a warning indication to the user.

    13.1.2 warnings

    whenever a cache returns a response that is neither first-hand nor
    "fresh enough" (in the sense of condition 2 in section 13.1.1), it
    must attach a warning to that effect, using a warning general-header.
    the warning header and the currently defined warnings are described
    in section 14.46. the warning allows clients to take appropriate
    action.

    warnings may be used for other purposes, both cache-related and
    otherwise. the use of a warning, rather than an error status code,
    distinguish these responses from true failures.

    warnings are assigned three digit warn-codes. the first digit
    indicates whether the warning must or must not be deleted from a
    stored cache entry after a successful revalidation:

    fielding, et al. standards track [page 76]

    rfc 2616 http/1.1 june 1999

    1xx warnings that describe the freshness or revalidation status of
    the response, and so must be deleted after a successful
    revalidation. 1xx warn-codes may be generated by a cache only when
    validating a cached entry. it must not be generated by clients.

    2xx warnings that describe some aspect of the entity body or entity
    headers that is not rectified by a revalidation (for example, a
    lossy compression of the entity bodies) and which must not be
    deleted after a successful revalidation.

    see section 14.46 for the definitions of the codes themselves.

    http/1.0 caches will cache all warnings in responses, without
    deleting the ones in the first category. warnings in responses that
    are passed to http/1.0 caches carry an extra warning-date field,
    which prevents a future http/1.1 recipient from believing an
    erroneously cached warning.

    warnings also carry a warning text. the text may be in any
    appropriate natural language (perhaps based on the client's accept
    headers), and include an optional indication of what character set is
    used.

    multiple warnings may be attached to a response (either by the origin
    server or by a cache), including multiple warnings with the same code
    number. for example, a server might provide the same warning with
    texts in both english and basque.

    when multiple warnings are attached to a response, it might not be
    practical or reasonable to display all of them to the user. this
    version of http does not specify strict priority rules for deciding
    which warnings to display and in what order, but does suggest some
    heuristics.

    13.1.3 cache-control mechanisms

    the basic cache mechanisms in http/1.1 (server-specified expiration
    times and validators) are implicit directives to caches. in some
    cases, a server or client might need to provide explicit directives
    to the http caches. we use the cache-control header for this purpose.

    the cache-control header allows a client or server to transmit a
    variety of directives in either requests or responses. these
    directives typically override the default caching algorithms. as a
    general rule, if there is any apparent conflict between header
    values, the most restrictive interpretation is applied (that is, the
    one that is most likely to preserve semantic transparency). however,

    fielding, et al. standards track [page 77]

    rfc 2616 http/1.1 june 1999

    in some cases, cache-control directives are explicitly specified as
    weakening the approximation of semantic transparency (for example,
    "max-stale" or "public").

    the cache-control directives are described in detail in section 14.9.

    13.1.4 explicit user agent warnings

    many user agents make it possible for users to override the basic
    caching mechanisms. for example, the user agent might allow the user
    to specify that cached entities (even explicitly stale ones) are
    never validated. or the user agent might habitually add "cache-
    control: max-stale=3600" to every request. the user agent should not
    default to either non-transparent behavior, or behavior that results
    in abnormally ineffective caching, but may be explicitly configured
    to do so by an explicit action of the user.

    if the user has overridden the basic caching mechanisms, the user
    agent should explicitly indicate to the user whenever this results in
    the display of information that might not meet the server's
    transparency requirements (in particular, if the displayed entity is
    known to be stale). since the protocol normally allows the user agent
    to determine if responses are stale or not, this indication need only
    be displayed when this actually happens. the indication need not be a
    dialog box; it could be an icon (for example, a picture of a rotting
    fish) or some other indicator.

    if the user has overridden the caching mechanisms in a way that would
    abnormally reduce the effectiveness of caches, the user agent should
    continually indicate this state to the user (for example, by a
    display of a picture of currency in flames) so that the user does not
    inadvertently consume excess resources or suffer from excessive
    latency.

    13.1.5 exceptions to the rules and warnings

    in some cases, the operator of a cache may choose to configure it to
    return stale responses even when not requested by clients. this
    decision ought not be made lightly, but may be necessary for reasons
    of availability or performance, especially when the cache is poorly
    connected to the origin server. whenever a cache returns a stale
    response, it must mark it as such (using a warning header) enabling
    the client software to alert the user that there might be a potential
    problem.

    fielding, et al. standards track [page 78]

    rfc 2616 http/1.1 june 1999

    it also allows the user agent to take steps to obtain a first-hand or
    fresh response. for this reason, a cache should not return a stale
    response if the client explicitly requests a first-hand or fresh one,
    unless it is impossible to comply for technical or policy reasons.

    13.1.6 client-controlled behavior

    while the origin server (and to a lesser extent, intermediate caches,
    by their contribution to the age of a response) are the primary
    source of expiration information, in some cases the client might need
    to control a cache's decision about whether to return a cached
    response without validating it. clients do this using several
    directives of the cache-control header.

    a client's request may specify the maximum age it is willing to
    accept of an unvalidated response; specifying a value of zero forces
    the cache(s) to revalidate all responses. a client may also specify
    the minimum time remaining before a response expires. both of these
    options increase constraints on the behavior of caches, and so cannot
    further relax the cache's approximation of semantic transparency.

    a client may also specify that it will accept stale responses, up to
    some maximum amount of staleness. this loosens the constraints on the
    caches, and so might violate the origin server's specified
    constraints on semantic transparency, but might be necessary to
    support disconnected operation, or high availability in the face of
    poor connectivity.

    13.2 expiration model

    13.2.1 server-specified expiration

    http caching works best when caches can entirely avoid making
    requests to the origin server. the primary mechanism for avoiding
    requests is for an origin server to provide an explicit expiration
    time in the future, indicating that a response may be used to satisfy
    subsequent requests. in other words, a cache can return a fresh
    response without first contacting the server.

    our expectation is that servers will assign future explicit
    expiration times to responses in the belief that the entity is not
    likely to change, in a semantically significant way, before the
    expiration time is reached. this normally preserves semantic
    transparency, as long as the server's expiration times are carefully
    chosen.

    fielding, et al. standards track [page 79]

    rfc 2616 http/1.1 june 1999

    the expiration mechanism applies only to responses taken from a cache
    and not to first-hand responses forwarded immediately to the
    requesting client.

    if an origin server wishes to force a semantically transparent cache
    to validate every request, it may assign an explicit expiration time
    in the past. this means that the response is always stale, and so the
    cache should validate it before using it for subsequent requests. see
    section 14.9.4 for a more restrictive way to force revalidation.

    if an origin server wishes to force any http/1.1 cache, no matter how
    it is configured, to validate every request, it should use the "must-
    revalidate" cache-control directive (see section 14.9).

    servers specify explicit expiration times using either the expires
    header, or the max-age directive of the cache-control header.

    an expiration time cannot be used to force a user agent to refresh
    its display or reload a resource; its semantics apply only to caching
    mechanisms, and such mechanisms need only check a resource's
    expiration status when a new request for that resource is initiated.
    see section 13.13 for an explanation of the difference between caches
    and history mechanisms.

    13.2.2 heuristic expiration

    since origin servers do not always provide explicit expiration times,
    http caches typically assign heuristic expiration times, employing
    algorithms that use other header values (such as the last-modified
    time) to estimate a plausible expiration time. the http/1.1
    specification does not provide specific algorithms, but does impose
    worst-case constraints on their results. since heuristic expiration
    times might compromise semantic transparency, they ought to used
    cautiously, and we encourage origin servers to provide explicit
    expiration times as much as possible.

    13.2.3 age calculations

    in order to know if a cached entry is fresh, a cache needs to know if
    its age exceeds its freshness lifetime. we discuss how to calculate
    the latter in section 13.2.4; this section describes how to calculate
    the age of a response or cache entry.

    in this discussion, we use the term "now" to mean "the current value
    of the clock at the host performing the calculation." hosts that use
    http, but especially hosts running origin servers and caches, should
    use ntp [28] or some similar protocol to synchronize their clocks to
    a globally accurate time standard.

    fielding, et al. standards track [page 80]

    rfc 2616 http/1.1 june 1999

    http/1.1 requires origin servers to send a date header, if possible,
    with every response, giving the time at which the response was
    generated (see section 14.18). we use the term "date_value" to denote
    the value of the date header, in a form appropriate for arithmetic
    operations.

    http/1.1 uses the age response-header to convey the estimated age of
    the response message when obtained from a cache. the age field value
    is the cache's estimate of the amount of time since the response was
    generated or revalidated by the origin server.

    in essence, the age value is the sum of the time that the response
    has been resident in each of the caches along the path from the
    origin server, plus the amount of time it has been in transit along
    network paths.

    we use the term "age_value" to denote the value of the age header, in
    a form appropriate for arithmetic operations.

    a response's age can be calculated in two entirely independent ways:

    1. now minus date_value, if the local clock is reasonably well
    synchronized to the origin server's clock. if the result is
    negative, the result is replaced by zero.

    2. age_value, if all of the caches along the response path
    implement http/1.1.

    given that we have two independent ways to compute the age of a
    response when it is received, we can combine these as

    corrected_received_age = max(now - date_value, age_value)

    and as long as we have either nearly synchronized clocks or all-
    http/1.1 paths, one gets a reliable (conservative) result.

    because of network-imposed delays, some significant interval might
    pass between the time that a server generates a response and the time
    it is received at the next outbound cache or client. if uncorrected,
    this delay could result in improperly low ages.

    because the request that resulted in the returned age value must have
    been initiated prior to that age value's generation, we can correct
    for delays imposed by the network by recording the time at which the
    request was initiated. then, when an age value is received, it must
    be interpreted relative to the time the request was initiated, not
  • fielding, et al. standards track [page 81]

    rfc 2616 http/1.1 june 1999

    the time that the response was received. this algorithm results in
    conservative behavior no matter how much delay is experienced. so, we
    compute:

    corrected_initial_age = corrected_received_age
    + (now - request_time)

    where "request_time" is the time (according to the local clock) when
    the request that elicited this response was sent.

    summary of age calculation algorithm, when a cache receives a
    response:

    /*
    * age_value
    * is the value of age: header received by the cache with
    * this response.
    * date_value
    * is the value of the origin server's date: header
    * request_time
    * is the (local) time when the cache made the request
    * that resulted in this cached response
    * response_time
    * is the (local) time when the cache received the
    * response
    * now
    * is the current (local) time
    */

    apparent_age = max(0, response_time - date_value);
    corrected_received_age = max(apparent_age, age_value);
    response_delay = response_time - request_time;
    corrected_initial_age = corrected_received_age + response_delay;
    resident_time = now - response_time;
    current_age = corrected_initial_age + resident_time;

    the current_age of a cache entry is calculated by adding the amount
    of time (in seconds) since the cache entry was last validated by the
    origin server to the corrected_initial_age. when a response is
    generated from a cache entry, the cache must include a single age
    header field in the response with a value equal to the cache entry's
    current_age.

    the presence of an age header field in a response implies that a
    response is not first-hand. however, the converse is not true, since
    the lack of an age header field in a response does not imply that the

    fielding, et al. standards track [page 82]

    rfc 2616 http/1.1 june 1999

    response is first-hand unless all caches along the request path are
    compliant with http/1.1 (i.e., older http caches did not implement
    the age header field).

    13.2.4 expiration calculations

    in order to decide whether a response is fresh or stale, we need to
    compare its freshness lifetime to its age. the age is calculated as
    described in section 13.2.3; this section describes how to calculate
    the freshness lifetime, and to determine if a response has expired.
    in the discussion below, the values can be represented in any form
    appropriate for arithmetic operations.

    we use the term "expires_value" to denote the value of the expires
    header. we use the term "max_age_value" to denote an appropriate
    value of the number of seconds carried by the "max-age" directive of
    the cache-control header in a response (see section 14.9.3).

    the max-age directive takes priority over expires, so if max-age is
    present in a response, the calculation is simply:

    freshness_lifetime = max_age_value

    otherwise, if expires is present in the response, the calculation is:

    freshness_lifetime = expires_value - date_value

    note that neither of these calculations is vulnerable to clock skew,
    since all of the information comes from the origin server.

    if none of expires, cache-control: max-age, or cache-control: s-
    maxage (see section 14.9.3) appears in the response, and the response
    does not include other restrictions on caching, the cache may compute
    a freshness lifetime using a heuristic. the cache must attach warning
    113 to any response whose age is more than 24 hours if such warning
    has not already been added.

    also, if the response does have a last-modified time, the heuristic
    expiration value should be no more than some fraction of the interval
    since that time. a typical setting of this fraction might be 10%.

    the calculation to determine if a response has expired is quite
    simple:

    response_is_fresh = (freshness_lifetime > current_age)

    fielding, et al. standards track [page 83]

    rfc 2616 http/1.1 june 1999

    13.2.5 disambiguating expiration values

    because expiration values are assigned optimistically, it is possible
    for two caches to contain fresh values for the same resource that are
    different.

    if a client performing a retrieval receives a non-first-hand response
    for a request that was already fresh in its own cache, and the date
    header in its existing cache entry is newer than the date on the new
    response, then the client may ignore the response. if so, it may
    retry the request with a "cache-control: max-age=0" directive (see
    section 14.9), to force a check with the origin server.

    if a cache has two fresh responses for the same representation with
    different validators, it must use the one with the more recent date
    header. this situation might arise because the cache is pooling
    responses from other caches, or because a client has asked for a
    reload or a revalidation of an apparently fresh cache entry.

    13.2.6 disambiguating multiple responses

    because a client might be receiving responses via multiple paths, so
    that some responses flow through one set of caches and other
    responses flow through a different set of caches, a client might
    receive responses in an order different from that in which the origin
    server sent them. we would like the client to use the most recently
    generated response, even if older responses are still apparently
    fresh.

    neither the entity tag nor the expiration value can impose an
    ordering on responses, since it is possible that a later response
    intentionally carries an earlier expiration time. the date values are
    ordered to a granularity of one second.

    when a client tries to revalidate a cache entry, and the response it
    receives contains a date header that appears to be older than the one
    for the existing entry, then the client should repeat the request
    unconditionally, and include

    cache-control: max-age=0

    to force any intermediate caches to validate their copies directly
    with the origin server, or

    cache-control: no-cache

    to force any intermediate caches to obtain a new copy from the origin
    server.

    fielding, et al. standards track [page 84]

    rfc 2616 http/1.1 june 1999

    if the date values are equal, then the client may use either response
    (or may, if it is being extremely prudent, request a new response).
    servers must not depend on clients being able to choose
    deterministically between responses generated during the same second,
    if their expiration times overlap.

    13.3 validation model

    when a cache has a stale entry that it would like to use as a
    response to a client's request, it first has to check with the origin
    server (or possibly an intermediate cache with a fresh response) to
    see if its cached entry is still usable. we call this "validating"
    the cache entry. since we do not want to have to pay the overhead of
    retransmitting the full response if the cached entry is good, and we
    do not want to pay the overhead of an extra round trip if the cached
    entry is invalid, the http/1.1 protocol supports the use of
    conditional methods.

    the key protocol features for supporting conditional methods are
    those concerned with "cache validators." when an origin server
    generates a full response, it attaches some sort of validator to it,
    which is kept with the cache entry. when a client (user agent or
    proxy cache) makes a conditional request for a resource for which it
    has a cache entry, it includes the associated validator in the
    request.

    the server then checks that validator against the current validator
    for the entity, and, if they match (see section 13.3.3), it responds
    with a special status code (usually, 304 (not modified)) and no
    entity-body. otherwise, it returns a full response (including
    entity-body). thus, we avoid transmitting the full response if the
    validator matches, and we avoid an extra round trip if it does not
    match.

    in http/1.1, a conditional request looks exactly the same as a normal
    request for the same resource, except that it carries a special
    header (which includes the validator) that implicitly turns the
    method (usually, get) into a conditional.

    the protocol includes both positive and negative senses of cache-
    validating conditions. that is, it is possible to request either that
    a method be performed if and only if a validator matches or if and
    only if no validators match.

    fielding, et al. standards track [page 85]

    rfc 2616 http/1.1 june 1999

    note: a response that lacks a validator may still be cached, and
    served from cache until it expires, unless this is explicitly
    prohibited by a cache-control directive. however, a cache cannot
    do a conditional retrieval if it does not have a validator for the
    entity, which means it will not be refreshable after it expires.

    13.3.1 last-modified dates

    the last-modified entity-header field value is often used as a cache
    validator. in simple terms, a cache entry is considered to be valid
    if the entity has not been modified since the last-modified value.

    13.3.2 entity tag cache validators

    the etag response-header field value, an entity tag, provides for an
    "opaque" cache validator. this might allow more reliable validation
    in situations where it is inconvenient to store modification dates,
    where the one-second resolution of http date values is not
    sufficient, or where the origin server wishes to avoid certain
    paradoxes that might arise from the use of modification dates.

    entity tags are described in section 3.11. the headers used with
    entity tags are described in sections 14.19, 14.24, 14.26 and 14.44.

    13.3.3 weak and strong validators

    since both origin servers and caches will compare two validators to
    decide if they represent the same or different entities, one normally
    would expect that if the entity (the entity-body or any entity-
    headers) changes in any way, then the associated validator would
    change as well. if this is true, then we call this validator a
    "strong validator."

    however, there might be cases when a server prefers to change the
    validator only on semantically significant changes, and not when
    insignificant aspects of the entity change. a validator that does not
    always change when the resource changes is a "weak validator."

    entity tags are normally "strong validators," but the protocol
    provides a mechanism to tag an entity tag as "weak." one can think of
    a strong validator as one that changes whenever the bits of an entity
    changes, while a weak value changes whenever the meaning of an entity
    changes. alternatively, one can think of a strong validator as part
    of an identifier for a specific entity, while a weak validator is
    part of an identifier for a set of semantically equivalent entities.

    note: one example of a strong validator is an integer that is
    incremented in stable storage every time an entity is changed.

    fielding, et al. standards track [page 86]

    rfc 2616 http/1.1 june 1999

    an entity's modification time, if represented with one-second
    resolution, could be a weak validator, since it is possible that
    the resource might be modified twice during a single second.

    support for weak validators is optional. however, weak validators
    allow for more efficient caching of equivalent objects; for
    example, a hit counter on a site is probably good enough if it is
    updated every few days or weeks, and any value during that period
    is likely "good enough" to be equivalent.

    a "use" of a validator is either when a client generates a request
    and includes the validator in a validating header field, or when a
    server compares two validators.

    strong validators are usable in any context. weak validators are only
    usable in contexts that do not depend on exact equality of an entity.
    for example, either kind is usable for a conditional get of a full
    entity. however, only a strong validator is usable for a sub-range
    retrieval, since otherwise the client might end up with an internally
    inconsistent entity.

    clients may issue simple (non-subrange) get requests with either weak
    validators or strong validators. clients must not use weak validators
    in other forms of request.

    the only function that the http/1.1 protocol defines on validators is
    comparison. there are two validator comparison functions, depending
    on whether the comparison context allows the use of weak validators
    or not:

    - the strong comparison function: in order to be considered equal,
    both validators must be identical in every way, and both must
    not be weak.

    - the weak comparison function: in order to be considered equal,
    both validators must be identical in every way, but either or
    both of them may be tagged as "weak" without affecting the
    result.

    an entity tag is strong unless it is explicitly tagged as weak.
    section 3.11 gives the syntax for entity tags.

    a last-modified time, when used as a validator in a request, is
    implicitly weak unless it is possible to deduce that it is strong,
    using the following rules:

    - the validator is being compared by an origin server to the
    actual current validator for the entity and,

    fielding, et al. standards track [page 87]

    rfc 2616 http/1.1 june 1999

    - that origin server reliably knows that the associated entity did
    not change twice during the second covered by the presented
    validator.

    or

    - the validator is about to be used by a client in an if-
    modified-since or if-unmodified-since header, because the client
    has a cache entry for the associated entity, and

    - that cache entry includes a date value, which gives the time
    when the origin server sent the original response, and

    - the presented last-modified time is at least 60 seconds before
    the date value.

    or

    - the validator is being compared by an intermediate cache to the
    validator stored in its cache entry for the entity, and

    - that cache entry includes a date value, which gives the time
    when the origin server sent the original response, and

    - the presented last-modified time is at least 60 seconds before
    the date value.

    this method relies on the fact that if two different responses were
    sent by the origin server during the same second, but both had the
    same last-modified time, then at least one of those responses would
    have a date value equal to its last-modified time. the arbitrary 60-
    second limit guards against the possibility that the date and last-
    modified values are generated from different clocks, or at somewhat
    different times during the preparation of the response. an
    implementation may use a value larger than 60 seconds, if it is
    believed that 60 seconds is too short.

    if a client wishes to perform a sub-range retrieval on a value for
    which it has only a last-modified time and no opaque validator, it
    may do this only if the last-modified time is strong in the sense
    described here.

    a cache or origin server receiving a conditional request, other than
    a full-body get request, must use the strong comparison function to
    evaluate the condition.

    these rules allow http/1.1 caches and clients to safely perform sub-
    range retrievals on values that have been obtained from http/1.0

    fielding, et al. standards track [page 88]

    rfc 2616 http/1.1 june 1999

    servers.

    13.3.4 rules for when to use entity tags and last-modified dates

    we adopt a set of rules and recommendations for origin servers,
    clients, and caches regarding when various validator types ought to
    be used, and for what purposes.

    http/1.1 origin servers:

    - should send an entity tag validator unless it is not feasible to
    generate one.

    - may send a weak entity tag instead of a strong entity tag, if
    performance considerations support the use of weak entity tags,
    or if it is unfeasible to send a strong entity tag.

    - should send a last-modified value if it is feasible to send one,
    unless the risk of a breakdown in semantic transparency that
    could result from using this date in an if-modified-since header
    would lead to serious problems.

    in other words, the preferred behavior for an http/1.1 origin server
    is to send both a strong entity tag and a last-modified value.

    in order to be legal, a strong entity tag must change whenever the
    associated entity value changes in any way. a weak entity tag should
    change whenever the associated entity changes in a semantically
    significant way.

    note: in order to provide semantically transparent caching, an
    origin server must avoid reusing a specific strong entity tag
    value for two different entities, or reusing a specific weak
    entity tag value for two semantically different entities. cache
    entries might persist for arbitrarily long periods, regardless of
    expiration times, so it might be inappropriate to expect that a
    cache will never again attempt to validate an entry using a
    validator that it obtained at some point in the past.

    http/1.1 clients:

    - if an entity tag has been provided by the origin server, must
    use that entity tag in any cache-conditional request (using if-
    match or if-none-match).

    - if only a last-modified value has been provided by the origin
    server, should use that value in non-subrange cache-conditional
    requests (using if-modified-since).

    fielding, et al. standards track [page 89]

    rfc 2616 http/1.1 june 1999

    - if only a last-modified value has been provided by an http/1.0
    origin server, may use that value in subrange cache-conditional
    requests (using if-unmodified-since:). the user agent should
    provide a way to disable this, in case of difficulty.

    - if both an entity tag and a last-modified value have been
    provided by the origin server, should use both validators in
    cache-conditional requests. this allows both http/1.0 and
    http/1.1 caches to respond appropriately.

    an http/1.1 origin server, upon receiving a conditional request that
    includes both a last-modified date (e.g., in an if-modified-since or
    if-unmodified-since header field) and one or more entity tags (e.g.,
    in an if-match, if-none-match, or if-range header field) as cache
    validators, must not return a response status of 304 (not modified)
    unless doing so is consistent with all of the conditional header
    fields in the request.

    an http/1.1 caching proxy, upon receiving a conditional request that
    includes both a last-modified date and one or more entity tags as
    cache validators, must not return a locally cached response to the
    client unless that cached response is consistent with all of the
    conditional header fields in the request.

    note: the general principle behind these rules is that http/1.1
    servers and clients should transmit as much non-redundant
    information as is available in their responses and requests.
    http/1.1 systems receiving this information will make the most
    conservative assumptions about the validators they receive.

    http/1.0 clients and caches will ignore entity tags. generally,
    last-modified values received or used by these systems will
    support transparent and efficient caching, and so http/1.1 origin
    servers should provide last-modified values. in those rare cases
    where the use of a last-modified value as a validator by an
    http/1.0 system could result in a serious problem, then http/1.1
    origin servers should not provide one.

    13.3.5 non-validating conditionals

    the principle behind entity tags is that only the service author
    knows the semantics of a resource well enough to select an
    appropriate cache validation mechanism, and the specification of any
    validator comparison function more complex than byte-equality would
    open up a can of worms. thus, comparisons of any other headers
    (except last-modified, for compatibility with http/1.0) are never
    used for purposes of validating a cache entry.

    fielding, et al. standards track [page 90]

    rfc 2616 http/1.1 june 1999

    13.4 response cacheability

    unless specifically constrained by a cache-control (section 14.9)
    directive, a caching system may always store a successful response
    (see section 13.8) as a cache entry, may return it without validation
    if it is fresh, and may return it after successful validation. if
    there is neither a cache validator nor an explicit expiration time
    associated with a response, we do not expect it to be cached, but
    certain caches may violate this expectation (for example, when little
    or no network connectivity is available). a client can usually detect
    that such a response was taken from a cache by comparing the date
    header to the current time.

    note: some http/1.0 caches are known to violate this expectation
    without providing any warning.

    however, in some cases it might be inappropriate for a cache to
    retain an entity, or to return it in response to a subsequent
    request. this might be because absolute semantic transparency is
    deemed necessary by the service author, or because of security or
    privacy considerations. certain cache-control directives are
    therefore provided so that the server can indicate that certain
    resource entities, or portions thereof, are not to be cached
    regardless of other considerations.

    note that section 14.8 normally prevents a shared cache from saving
    and returning a response to a previous request if that request
    included an authorization header.

    a response received with a status code of 200, 203, 206, 300, 301 or
    410 may be stored by a cache and used in reply to a subsequent
    request, subject to the expiration mechanism, unless a cache-control
    directive prohibits caching. however, a cache that does not support
    the range and content-range headers must not cache 206 (partial
    content) responses.

    a response received with any other status code (e.g. status codes 302
    and 307) must not be returned in a reply to a subsequent request
    unless there are cache-control directives or another header(s) that
    explicitly allow it. for example, these include the following: an
    expires header (section 14.21); a "max-age", "s-maxage", "must-
    revalidate", "proxy-revalidate", "public" or "private" cache-control
    directive (section 14.9).
  • fielding, et al. standards track [page 91]

    rfc 2616 http/1.1 june 1999

    13.5 constructing responses from caches

    the purpose of an http cache is to store information received in
    response to requests for use in responding to future requests. in
    many cases, a cache simply returns the appropriate parts of a
    response to the requester. however, if the cache holds a cache entry
    based on a previous response, it might have to combine parts of a new
    response with what is held in the cache entry.

    13.5.1 end-to-end and hop-by-hop headers

    for the purpose of defining the behavior of caches and non-caching
    proxies, we divide http headers into two categories:

    - end-to-end headers, which are transmitted to the ultimate
    recipient of a request or response. end-to-end headers in
    responses must be stored as part of a cache entry and must be
    transmitted in any response formed from a cache entry.

    - hop-by-hop headers, which are meaningful only for a single
    transport-level connection, and are not stored by caches or
    forwarded by proxies.

    the following http/1.1 headers are hop-by-hop headers:

    - connection
    - keep-alive
    - proxy-authenticate
    - proxy-authorization
    - te
    - trailers
    - transfer-encoding
    - upgrade

    all other headers defined by http/1.1 are end-to-end headers.

    other hop-by-hop headers must be listed in a connection header,
    (section 14.10) to be introduced into http/1.1 (or later).

    13.5.2 non-modifiable headers

    some features of the http/1.1 protocol, such as digest
    authentication, depend on the value of certain end-to-end headers. a
    transparent proxy should not modify an end-to-end header unless the
    definition of that header requires or specifically allows that.

    fielding, et al. standards track [page 92]

    rfc 2616 http/1.1 june 1999

    a transparent proxy must not modify any of the following fields in a
    request or response, and it must not add any of these fields if not
    already present:

    - content-location

    - content-md5

    - etag

    - last-modified

    a transparent proxy must not modify any of the following fields in a
    response:

    - expires

    but it may add any of these fields if not already present. if an
    expires header is added, it must be given a field-value identical to
    that of the date header in that response.

    a proxy must not modify or add any of the following fields in a
    message that contains the no-transform cache-control directive, or in
    any request:

    - content-encoding

    - content-range

    - content-type

    a non-transparent proxy may modify or add these fields to a message
    that does not include no-transform, but if it does so, it must add a
    warning 214 (transformation applied) if one does not already appear
    in the message (see section 14.46).

    warning: unnecessary modification of end-to-end headers might
    cause authentication failures if stronger authentication
    mechanisms are introduced in later versions of http. such
    authentication mechanisms may rely on the values of header fields
    not listed here.

    the content-length field of a request or response is added or deleted
    according to the rules in section 4.4. a transparent proxy must
    preserve the entity-length (section 7.2.2) of the entity-body,
    although it may change the transfer-length (section 4.4).

    fielding, et al. standards track [page 93]

    rfc 2616 http/1.1 june 1999

    13.5.3 combining headers

    when a cache makes a validating request to a server, and the server
    provides a 304 (not modified) response or a 206 (partial content)
    response, the cache then constructs a response to send to the
    requesting client.

    if the status code is 304 (not modified), the cache uses the entity-
    body stored in the cache entry as the entity-body of this outgoing
    response. if the status code is 206 (partial content) and the etag or
    last-modified headers match exactly, the cache may combine the
    contents stored in the cache entry with the new contents received in
    the response and use the result as the entity-body of this outgoing
    response, (see 13.5.4).

    the end-to-end headers stored in the cache entry are used for the
    constructed response, except that

    - any stored warning headers with warn-code 1xx (see section
    14.46) must be deleted from the cache entry and the forwarded
    response.

    - any stored warning headers with warn-code 2xx must be retained
    in the cache entry and the forwarded response.

    - any end-to-end headers provided in the 304 or 206 response must
    replace the corresponding headers from the cache entry.

    unless the cache decides to remove the cache entry, it must also
    replace the end-to-end headers stored with the cache entry with
    corresponding headers received in the incoming response, except for
    warning headers as described immediately above. if a header field-
    name in the incoming response matches more than one header in the
    cache entry, all such old headers must be replaced.

    in other words, the set of end-to-end headers received in the
    incoming response overrides all corresponding end-to-end headers
    stored with the cache entry (except for stored warning headers with
    warn-code 1xx, which are deleted even if not overridden).

    note: this rule allows an origin server to use a 304 (not
    modified) or a 206 (partial content) response to update any header
    associated with a previous response for the same entity or sub-
    ranges thereof, although it might not always be meaningful or
    correct to do so. this rule does not allow an origin server to use
    a 304 (not modified) or a 206 (partial content) response to
    entirely delete a header that it had provided with a previous
    response.

    fielding, et al. standards track [page 94]

    rfc 2616 http/1.1 june 1999

    13.5.4 combining byte ranges

    a response might transfer only a subrange of the bytes of an entity-
    body, either because the request included one or more range
    specifications, or because a connection was broken prematurely. after
    several such transfers, a cache might have received several ranges of
    the same entity-body.

    if a cache has a stored non-empty set of subranges for an entity, and
    an incoming response transfers another subrange, the cache may
    combine the new subrange with the existing set if both the following
    conditions are met:

    - both the incoming response and the cache entry have a cache
    validator.

    - the two cache validators match using the strong comparison
    function (see section 13.3.3).

    if either requirement is not met, the cache must use only the most
    recent partial response (based on the date values transmitted with
    every response, and using the incoming response if these values are
    equal or missing), and must discard the other partial information.

    13.6 caching negotiated responses

    use of server-driven content negotiation (section 12.1), as indicated
    by the presence of a vary header field in a response, alters the
    conditions and procedure by which a cache can use the response for
    subsequent requests. see section 14.44 for use of the vary header
    field by servers.

    a server should use the vary header field to inform a cache of what
    request-header fields were used to select among multiple
    representations of a cacheable response subject to server-driven
    negotiation. the set of header fields named by the vary field value
    is known as the "selecting" request-headers.

    when the cache receives a subsequent request whose request-uri
    specifies one or more cache entries including a vary header field,
    the cache must not use such a cache entry to construct a response to
    the new request unless all of the selecting request-headers present
    in the new request match the corresponding stored request-headers in
    the original request.

    the selecting request-headers from two requests are defined to match
    if and only if the selecting request-headers in the first request can
    be transformed to the selecting request-headers in the second request

    fielding, et al. standards track [page 95]

    rfc 2616 http/1.1 june 1999

    by adding or removing linear white space (lws) at places where this
    is allowed by the corresponding bnf, and/or combining multiple
    message-header fields with the same field name following the rules
    about message headers in section 4.2.

    a vary header field-value of "*" always fails to match and subsequent
    requests on that resource can only be properly interpreted by the
    origin server.

    if the selecting request header fields for the cached entry do not
    match the selecting request header fields of the new request, then
    the cache must not use a cached entry to satisfy the request unless
    it first relays the new request to the origin server in a conditional
    request and the server responds with 304 (not modified), including an
    entity tag or content-location that indicates the entity to be used.

    if an entity tag was assigned to a cached representation, the
    forwarded request should be conditional and include the entity tags
    in an if-none-match header field from all its cache entries for the
    resource. this conveys to the server the set of entities currently
    held by the cache, so that if any one of these entities matches the
    requested entity, the server can use the etag header field in its 304
    (not modified) response to tell the cache which entry is appropriate.
    if the entity-tag of the new response matches that of an existing
    entry, the new response should be used to update the header fields of
    the existing entry, and the result must be returned to the client.

    if any of the existing cache entries contains only partial content
    for the associated entity, its entity-tag should not be included in
    the if-none-match header field unless the request is for a range that
    would be fully satisfied by that entry.

    if a cache receives a successful response whose content-location
    field matches that of an existing cache entry for the same request-
    ]uri, whose entity-tag differs from that of the existing entry, and
    whose date is more recent than that of the existing entry, the
    existing entry should not be returned in response to future requests
    and should be deleted from the cache.

    13.7 shared and non-shared caches

    for reasons of security and privacy, it is necessary to make a
    distinction between "shared" and "non-shared" caches. a non-shared
    cache is one that is accessible only to a single user. accessibility
    in this case should be enforced by appropriate security mechanisms.
    all other caches are considered to be "shared." other sections of

    fielding, et al. standards track [page 96]

    rfc 2616 http/1.1 june 1999

    this specification place certain constraints on the operation of
    shared caches in order to prevent loss of privacy or failure of
    access controls.

    13.8 errors or incomplete response cache behavior

    a cache that receives an incomplete response (for example, with fewer
    bytes of data than specified in a content-length header) may store
    the response. however, the cache must treat this as a partial
    response. partial responses may be combined as described in section
    13.5.4; the result might be a full response or might still be
    partial. a cache must not return a partial response to a client
    without explicitly marking it as such, using the 206 (partial
    content) status code. a cache must not return a partial response
    using a status code of 200 (ok).

    if a cache receives a 5xx response while attempting to revalidate an
    entry, it may either forward this response to the requesting client,
    or act as if the server failed to respond. in the latter case, it may
    return a previously received response unless the cached entry
    includes the "must-revalidate" cache-control directive (see section
    14.9).

    13.9 side effects of get and head

    unless the origin server explicitly prohibits the caching of their
    responses, the application of get and head methods to any resources
    should not have side effects that would lead to erroneous behavior if
    these responses are taken from a cache. they may still have side
    effects, but a cache is not required to consider such side effects in
    its caching decisions. caches are always expected to observe an
    origin server's explicit restrictions on caching.

    we note one exception to this rule: since some applications have
    traditionally used gets and heads with query urls (those containing a
    "?" in the rel_path part) to perform operations with significant side
    effects, caches must not treat responses to such uris as fresh unless
    the server provides an explicit expiration time. this specifically
    means that responses from http/1.0 servers for such uris should not
    be taken from a cache. see section 9.1.1 for related information.

    13.10 invalidation after updates or deletions

    the effect of certain methods performed on a resource at the origin
    server might cause one or more existing cache entries to become non-
    transparently invalid. that is, although they might continue to be
    "fresh," they do not accurately reflect what the origin server would
    return for a new request on that resource.

    fielding, et al. standards track [page 97]

    rfc 2616 http/1.1 june 1999

    there is no way for the http protocol to guarantee that all such
    cache entries are marked invalid. for example, the request that
    caused the change at the origin server might not have gone through
    the proxy where a cache entry is stored. however, several rules help
    reduce the likelihood of erroneous behavior.

    in this section, the phrase "invalidate an entity" means that the
    cache will either remove all instances of that entity from its
    storage, or will mark these as "invalid" and in need of a mandatory
    revalidation before they can be returned in response to a subsequent
    request.

    some http methods must cause a cache to invalidate an entity. this is
    either the entity referred to by the request-uri, or by the location
    or content-location headers (if present). these methods are:

    - put

    - delete

    - post

    in order to prevent denial of service attacks, an invalidation based
    on the uri in a location or content-location header must only be
    performed if the host part is the same as in the request-uri.

    a cache that passes through requests for methods it does not
    understand should invalidate any entities referred to by the
    request-uri.

    13.11 write-through mandatory

    all methods that might be expected to cause modifications to the
    origin server's resources must be written through to the origin
    server. this currently includes all methods except for get and head.
    a cache must not reply to such a request from a client before having
    transmitted the request to the inbound server, and having received a
    corresponding response from the inbound server. this does not prevent
    a proxy cache from sending a 100 (continue) response before the
    inbound server has sent its final reply.

    the alternative (known as "write-back" or "copy-back" caching) is not
    allowed in http/1.1, due to the difficulty of providing consistent
    updates and the problems arising from server, cache, or network
    failure prior to write-back.

    fielding, et al. standards track [page 98]

    rfc 2616 http/1.1 june 1999

    13.12 cache replacement

    if a new cacheable (see sections 14.9.2, 13.2.5, 13.2.6 and 13.8)
    response is received from a resource while any existing responses for
    the same resource are cached, the cache should use the new response
    to reply to the current request. it may insert it into cache storage
    and may, if it meets all other requirements, use it to respond to any
    future requests that would previously have caused the old response to
    be returned. if it inserts the new response into cache storage the
    rules in section 13.5.3 apply.

    note: a new response that has an older date header value than
    existing cached responses is not cacheable.

    13.13 history lists

    user agents often have history mechanisms, such as "back" buttons and
    history lists, which can be used to redisplay an entity retrieved
    earlier in a session.

    history mechanisms and caches are different. in particular history
    mechanisms should not try to show a semantically transparent view of
    the current state of a resource. rather, a history mechanism is meant
    to show exactly what the user saw at the time when the resource was
    retrieved.

    by default, an expiration time does not apply to history mechanisms.
    if the entity is still in storage, a history mechanism should display
    it even if the entity has expired, unless the user has specifically
    configured the agent to refresh expired history documents.

    this is not to be construed to prohibit the history mechanism from
    telling the user that a view might be stale.

    note: if history list mechanisms unnecessarily prevent users from
    viewing stale resources, this will tend to force service authors
    to avoid using http expiration controls and cache controls when
    they would otherwise like to. service authors may consider it
    important that users not be presented with error messages or
    warning messages when they use navigation controls (such as back)
    to view previously fetched resources. even though sometimes such
    resources ought not to cached, or ought to expire quickly, user
    interface considerations may force service authors to resort to
    other means of preventing caching (e.g. "once-only" urls) in order
    not to suffer the effects of improperly functioning history
    mechanisms.

    fielding, et al. standards track [page 99]

    rfc 2616 http/1.1 june 1999

    14 header field definitions

    this section defines the syntax and semantics of all standard
    http/1.1 header fields. for entity-header fields, both sender and
    recipient refer to either the client or the server, depending on who
    sends and who receives the entity.

    14.1 accept

    the accept request-header field can be used to specify certain media
    types which are acceptable for the response. accept headers can be
    used to indicate that the request is specifically limited to a small
    set of desired types, as in the case of a request for an in-line
    image.

    accept = "accept" ":"
    #( media-range [ accept-params ] )

    media-range = ( "*/*"
    | ( type "/" "*" )
    | ( type "/" subtype )
    ) *( ";" parameter )
    accept-params = ";" "q" "=" qvalue *( accept-extension )
    accept-extension = ";" token [ "=" ( token | quoted-string ) ]

    the asterisk "*" character is used to group media types into ranges,
    with "*/*" indicating all media types and "type/*" indicating all
    subtypes of that type. the media-range may include media type
    parameters that are applicable to that range.

    each media-range may be followed by one or more accept-params,
    beginning with the "q" parameter for indicating a relative quality
    factor. the first "q" parameter (if any) separates the media-range
    parameter(s) from the accept-params. quality factors allow the user
    or user agent to indicate the relative degree of preference for that
    media-range, using the qvalue scale from 0 to 1 (section 3.9). the
    default value is q=1.

    note: use of the "q" parameter name to separate media type
    parameters from accept extension parameters is due to historical
    practice. although this prevents any media type parameter named
    "q" from being used with a media range, such an event is believed
    to be unlikely given the lack of any "q" parameters in the iana
    media type registry and the rare usage of any media type
    parameters in accept. future media types are discouraged from
    registering any parameter named "q".

    fielding, et al. standards track [page 100]

    rfc 2616 http/1.1 june 1999

    the example

    accept: audio/*; q=0.2, audio/basic

    should be interpreted as "i prefer audio/basic, but send me any audio
    type if it is the best available after an 80% mark-down in quality."

    if no accept header field is present, then it is assumed that the
    client accepts all media types. if an accept header field is present,
    and if the server cannot send a response which is acceptable
    according to the combined accept field value, then the server should
    send a 406 (not acceptable) response.

    a more elaborate example is

    accept: text/plain; q=0.5, text/html,
    text/x-dvi; q=0.8, text/x-c

    verbally, this would be interpreted as "text/html and text/x-c are
    the preferred media types, but if they do not exist, then send the
    text/x-dvi entity, and if that does not exist, send the text/plain
    entity."

    media ranges can be overridden by more specific media ranges or
    specific media types. if more than one media range applies to a given
    type, the most specific reference has precedence. for example,

    accept: text/*, text/html, text/html;level=1, */*

    have the following precedence:

    1) text/html;level=1
    2) text/html
    3) text/*
    4) */*

    the media type quality factor associated with a given type is
    determined by finding the media range with the highest precedence
    which matches that type. for example,

    accept: text/*;q=0.3, text/html;q=0.7, text/html;level=1,
    text/html;level=2;q=0.4, */*;q=0.5

    would cause the following values to be associated:

    text/html;level=1 = 1
    text/html = 0.7
    text/plain = 0.3
  • fielding, et al. standards track [page 101]

    rfc 2616 http/1.1 june 1999

    image/jpeg = 0.5
    text/html;level=2 = 0.4
    text/html;level=3 = 0.7

    note: a user agent might be provided with a default set of quality
    values for certain media ranges. however, unless the user agent is
    a closed system which cannot interact with other rendering agents,
    this default set ought to be configurable by the user.

    14.2 accept-charset

    the accept-charset request-header field can be used to indicate what
    character sets are acceptable for the response. this field allows
    clients capable of understanding more comprehensive or special-
    purpose character sets to signal that capability to a server which is
    capable of representing documents in those character sets.

    accept-charset = "accept-charset" ":"
    1#( ( charset | "*" )[ ";" "q" "=" qvalue ] )

    character set values are described in section 3.4. each charset may
    be given an associated quality value which represents the user's
    preference for that charset. the default value is q=1. an example is

    accept-charset: iso-8859-5, unicode-1-1;q=0.8

    the special value "*", if present in the accept-charset field,
    matches every character set (including iso-8859-1) which is not
    mentioned elsewhere in the accept-charset field. if no "*" is present
    in an accept-charset field, then all character sets not explicitly
    mentioned get a quality value of 0, except for iso-8859-1, which gets
    a quality value of 1 if not explicitly mentioned.

    if no accept-charset header is present, the default is that any
    character set is acceptable. if an accept-charset header is present,
    and if the server cannot send a response which is acceptable
    according to the accept-charset header, then the server should send
    an error response with the 406 (not acceptable) status code, though
    the sending of an unacceptable response is also allowed.

    14.3 accept-encoding

    the accept-encoding request-header field is similar to accept, but
    restricts the content-codings (section 3.5) that are acceptable in
    the response.

    accept-encoding = "accept-encoding" ":"

    fielding, et al. standards track [page 102]

    rfc 2616 http/1.1 june 1999

    1#( codings [ ";" "q" "=" qvalue ] )
    codings = ( content-coding | "*" )

    examples of its use are:

    accept-encoding: compress, gzip
    accept-encoding:
    accept-encoding: *
    accept-encoding: compress;q=0.5, gzip;q=1.0
    accept-encoding: gzip;q=1.0, identity; q=0.5, *;q=0

    a server tests whether a content-coding is acceptable, according to
    an accept-encoding field, using these rules:

    1. if the content-coding is one of the content-codings listed in
    the accept-encoding field, then it is acceptable, unless it is
    accompanied by a qvalue of 0. (as defined in section 3.9, a
    qvalue of 0 means "not acceptable.")

    2. the special "*" symbol in an accept-encoding field matches any
    available content-coding not explicitly listed in the header
    field.

    3. if multiple content-codings are acceptable, then the acceptable
    content-coding with the highest non-zero qvalue is preferred.

    4. the "identity" content-coding is always acceptable, unless
    specifically refused because the accept-encoding field includes
    "identity;q=0", or because the field includes "*;q=0" and does
    not explicitly include the "identity" content-coding. if the
    accept-encoding field-value is empty, then only the "identity"
    encoding is acceptable.

    if an accept-encoding field is present in a request, and if the
    server cannot send a response which is acceptable according to the
    accept-encoding header, then the server should send an error response
    with the 406 (not acceptable) status code.

    if no accept-encoding field is present in a request, the server may
    assume that the client will accept any content coding. in this case,
    if "identity" is one of the available content-codings, then the
    server should use the "identity" content-coding, unless it has
    additional information that a different content-coding is meaningful
    to the client.

    note: if the request does not include an accept-encoding field,
    and if the "identity" content-coding is unavailable, then
    content-codings commonly understood by http/1.0 clients (i.e.,

    fielding, et al. standards track [page 103]

    rfc 2616 http/1.1 june 1999

    "gzip" and "compress") are preferred; some older clients
    improperly display messages sent with other content-codings. the
    server might also make this decision based on information about
    the particular user-agent or client.

    note: most http/1.0 applications do not recognize or obey qvalues
    associated with content-codings. this means that qvalues will not
    work and are not permitted with x-gzip or x-compress.

    14.4 accept-language

    the accept-language request-header field is similar to accept, but
    restricts the set of natural languages that are preferred as a
    response to the request. language tags are defined in section 3.10.

    accept-language = "accept-language" ":"
    1#( language-range [ ";" "q" "=" qvalue ] )
    language-range = ( ( 1*8alpha *( "-" 1*8alpha ) ) | "*" )

    each language-range may be given an associated quality value which
    represents an estimate of the user's preference for the languages
    specified by that range. the quality value defaults to "q=1". for
    example,

    accept-language: da, en-gb;q=0.8, en;q=0.7

    would mean: "i prefer danish, but will accept british english and
    other types of english." a language-range matches a language-tag if
    it exactly equals the tag, or if it exactly equals a prefix of the
    tag such that the first tag character following the prefix is "-".
    the special range "*", if present in the accept-language field,
    matches every tag not matched by any other range present in the
    accept-language field.

    note: this use of a prefix matching rule does not imply that
    language tags are assigned to languages in such a way that it is
    always true that if a user understands a language with a certain
    tag, then this user will also understand all languages with tags
    for which this tag is a prefix. the prefix rule simply allows the
    use of prefix tags if this is the case.

    the language quality factor assigned to a language-tag by the
    accept-language field is the quality value of the longest language-
    range in the field that matches the language-tag. if no language-
    range in the field matches the tag, the language quality factor
    assigned is 0. if no accept-language header is present in the
    request, the server

    fielding, et al. standards track [page 104]

    rfc 2616 http/1.1 june 1999

    should assume that all languages are equally acceptable. if an
    accept-language header is present, then all languages which are
    assigned a quality factor greater than 0 are acceptable.

    it might be contrary to the privacy expectations of the user to send
    an accept-language header with the complete linguistic preferences of
    the user in every request. for a discussion of this issue, see
    section 15.1.4.

    as intelligibility is highly dependent on the individual user, it is
    recommended that client applications make the choice of linguistic
    preference available to the user. if the choice is not made
    available, then the accept-language header field must not be given in
    the request.

    note: when making the choice of linguistic preference available to
    the user, we remind implementors of the fact that users are not
    familiar with the details of language matching as described above,
    and should provide appropriate guidance. as an example, users
    might assume that on selecting "en-gb", they will be served any
    kind of english document if british english is not available. a
    user agent might suggest in such a case to add "en" to get the
    best matching behavior.

    14.5 accept-ranges

    the accept-ranges response-header field allows the server to
    indicate its acceptance of range requests for a resource:

    accept-ranges = "accept-ranges" ":" acceptable-ranges
    acceptable-ranges = 1#range-unit | "none"

    origin servers that accept byte-range requests may send

    accept-ranges: bytes

    but are not required to do so. clients may generate byte-range
    requests without having received this header for the resource
    involved. range units are defined in section 3.12.

    servers that do not accept any kind of range request for a
    resource may send

    accept-ranges: none

    to advise the client not to attempt a range request.

    fielding, et al. standards track [page 105]

    rfc 2616 http/1.1 june 1999

    14.6 age

    the age response-header field conveys the sender's estimate of the
    amount of time since the response (or its revalidation) was
    generated at the origin server. a cached response is "fresh" if
    its age does not exceed its freshness lifetime. age values are
    calculated as specified in section 13.2.3.

    age = "age" ":" age-value
    age-value = delta-seconds

    age values are non-negative decimal integers, representing time in
    seconds.

    if a cache receives a value larger than the largest positive
    integer it can represent, or if any of its age calculations
    overflows, it must transmit an age header with a value of
    2147483648 (2^31). an http/1.1 server that includes a cache must
    include an age header field in every response generated from its
    own cache. caches should use an arithmetic type of at least 31
    bits of range.

    14.7 allow

    the allow entity-header field lists the set of methods supported
    by the resource identified by the request-uri. the purpose of this
    field is strictly to inform the recipient of valid methods
    associated with the resource. an allow header field must be
    present in a 405 (method not allowed) response.

    allow = "allow" ":" #method

    example of use:

    allow: get, head, put

    this field cannot prevent a client from trying other methods.
    however, the indications given by the allow header field value
    should be followed. the actual set of allowed methods is defined
    by the origin server at the time of each request.

    the allow header field may be provided with a put request to
    recommend the methods to be supported by the new or modified
    resource. the server is not required to support these methods and
    should include an allow header in the response giving the actual
    supported methods.

    fielding, et al. standards track [page 106]

    rfc 2616 http/1.1 june 1999

    a proxy must not modify the allow header field even if it does not
    understand all the methods specified, since the user agent might
    have other means of communicating with the origin server.

    14.8 authorization

    a user agent that wishes to authenticate itself with a server--
    usually, but not necessarily, after receiving a 401 response--does
    so by including an authorization request-header field with the
    request. the authorization field value consists of credentials
    containing the authentication information of the user agent for
    the realm of the resource being requested.

    authorization = "authorization" ":" credentials

    http access authentication is described in "http authentication:
    basic and digest access authentication" [43]. if a request is
    authenticated and a realm specified, the same credentials should
    be valid for all other requests within this realm (assuming that
    the authentication scheme itself does not require otherwise, such
    as credentials that vary according to a challenge value or using
    synchronized clocks).

    when a shared cache (see section 13.7) receives a request
    containing an authorization field, it must not return the
    corresponding response as a reply to any other request, unless one
    of the following specific exceptions holds:

    1. if the response includes the "s-maxage" cache-control
    directive, the cache may use that response in replying to a
    subsequent request. but (if the specified maximum age has
    passed) a proxy cache must first revalidate it with the origin
    server, using the request-headers from the new request to allow
    the origin server to authenticate the new request. (this is the
    defined behavior for s-maxage.) if the response includes "s-
    maxage=0", the proxy must always revalidate it before re-using
    it.

    2. if the response includes the "must-revalidate" cache-control
    directive, the cache may use that response in replying to a
    subsequent request. but if the response is stale, all caches
    must first revalidate it with the origin server, using the
    request-headers from the new request to allow the origin server
    to authenticate the new request.

    3. if the response includes the "public" cache-control directive,
    it may be returned in reply to any subsequent request.

    fielding, et al. standards track [page 107]

    rfc 2616 http/1.1 june 1999

    14.9 cache-control

    the cache-control general-header field is used to specify directives
    that must be obeyed by all caching mechanisms along the
    request/response chain. the directives specify behavior intended to
    prevent caches from adversely interfering with the request or
    response. these directives typically override the default caching
    algorithms. cache directives are unidirectional in that the presence
    of a directive in a request does not imply that the same directive is
    to be given in the response.

    note that http/1.0 caches might not implement cache-control and
    might only implement pragma: no-cache (see section 14.32).

    cache directives must be passed through by a proxy or gateway
    application, regardless of their significance to that application,
    since the directives might be applicable to all recipients along the
    request/response chain. it is not possible to specify a cache-
    directive for a specific cache.

    cache-control = "cache-control" ":" 1#cache-directive

    cache-directive = cache-request-directive
    | cache-response-directive

    cache-request-directive =
    "no-cache" ; section 14.9.1
    | "no-store" ; section 14.9.2
    | "max-age" "=" delta-seconds ; section 14.9.3, 14.9.4
    | "max-stale" [ "=" delta-seconds ] ; section 14.9.3
    | "min-fresh" "=" delta-seconds ; section 14.9.3
    | "no-transform" ; section 14.9.5
    | "only-if-cached" ; section 14.9.4
    | cache-extension ; section 14.9.6

    cache-response-directive =
    "public" ; section 14.9.1
    | "private" [ "=" <"> 1#field-name <"> ] ; section 14.9.1
    | "no-cache" [ "=" <"> 1#field-name <"> ]; section 14.9.1
    | "no-store" ; section 14.9.2
    | "no-transform" ; section 14.9.5
    | "must-revalidate" ; section 14.9.4
    | "proxy-revalidate" ; section 14.9.4
    | "max-age" "=" delta-seconds ; section 14.9.3
    | "s-maxage" "=" delta-seconds ; section 14.9.3
    | cache-extension ; section 14.9.6

    cache-extension = token [ "=" ( token | quoted-string ) ]

    fielding, et al. standards track [page 108]

    rfc 2616 http/1.1 june 1999

    when a directive appears without any 1#field-name parameter, the
    directive applies to the entire request or response. when such a
    directive appears with a 1#field-name parameter, it applies only to
    the named field or fields, and not to the rest of the request or
    response. this mechanism supports extensibility; implementations of
    future versions of the http protocol might apply these directives to
    header fields not defined in http/1.1.

    the cache-control directives can be broken down into these general
    categories:

    - restrictions on what are cacheable; these may only be imposed by
    the origin server.

    - restrictions on what may be stored by a cache; these may be
    imposed by either the origin server or the user agent.

    - modifications of the basic expiration mechanism; these may be
    imposed by either the origin server or the user agent.

    - controls over cache revalidation and reload; these may only be
    imposed by a user agent.

    - control over transformation of entities.

    - extensions to the caching system.

    14.9.1 what is cacheable

    by default, a response is cacheable if the requirements of the
    request method, request header fields, and the response status
    indicate that it is cacheable. section 13.4 summarizes these defaults
    for cacheability. the following cache-control response directives
    allow an origin server to override the default cacheability of a
    response:

    public
    indicates that the response may be cached by any cache, even if it
    would normally be non-cacheable or cacheable only within a non-
    shared cache. (see also authorization, section 14.8, for
    additional details.)

    private
    indicates that all or part of the response message is intended for
    a single user and must not be cached by a shared cache. this
    allows an origin server to state that the specified parts of the

    fielding, et al. standards track [page 109]

    rfc 2616 http/1.1 june 1999

    response are intended for only one user and are not a valid
    response for requests by other users. a private (non-shared) cache
    may cache the response.

    note: this usage of the word private only controls where the
    response may be cached, and cannot ensure the privacy of the
    message content.

    no-cache
    if the no-cache directive does not specify a field-name, then a
    cache must not use the response to satisfy a subsequent request
    without successful revalidation with the origin server. this
    allows an origin server to prevent caching even by caches that
    have been configured to return stale responses to client requests.

    if the no-cache directive does specify one or more field-names,
    then a cache may use the response to satisfy a subsequent request,
    subject to any other restrictions on caching. however, the
    specified field-name(s) must not be sent in the response to a
    subsequent request without successful revalidation with the origin
    server. this allows an origin server to prevent the re-use of
    certain header fields in a response, while still allowing caching
    of the rest of the response.

    note: most http/1.0 caches will not recognize or obey this
    directive.

    14.9.2 what may be stored by caches

    no-store
    the purpose of the no-store directive is to prevent the
    inadvertent release or retention of sensitive information (for
    example, on backup tapes). the no-store directive applies to the
    entire message, and may be sent either in a response or in a
    request. if sent in a request, a cache must not store any part of
    either this request or any response to it. if sent in a response,
    a cache must not store any part of either this response or the
    request that elicited it. this directive applies to both non-
    shared and shared caches. "must not store" in this context means
    that the cache must not intentionally store the information in
    non-volatile storage, and must make a best-effort attempt to
    remove the information from volatile storage as promptly as
    possible after forwarding it.

    even when this directive is associated with a response, users
    might explicitly store such a response outside of the caching
    system (e.g., with a "save as" dialog). history buffers may store
    such responses as part of their normal operation.

    fielding, et al. standards track [page 110]

    rfc 2616 http/1.1 june 1999

    the purpose of this directive is to meet the stated requirements
    of certain users and service authors who are concerned about
    accidental releases of information via unanticipated accesses to
    cache data structures. while the use of this directive might
    improve privacy in some cases, we caution that it is not in any
    way a reliable or sufficient mechanism for ensuring privacy. in
    particular, malicious or compromised caches might not recognize or
    obey this directive, and communications networks might be
    vulnerable to eavesdropping.

    14.9.3 modifications of the basic expiration mechanism

    the expiration time of an entity may be specified by the origin
    server using the expires header (see section 14.21). alternatively,
    it may be specified using the max-age directive in a response. when
    the max-age cache-control directive is present in a cached response,
    the response is stale if its current age is greater than the age
    value given (in seconds) at the time of a new request for that
    resource. the max-age directive on a response implies that the
    response is cacheable (i.e., "public") unless some other, more
    restrictive cache directive is also present.

    if a response includes both an expires header and a max-age
    directive, the max-age directive overrides the expires header, even
    if the expires header is more restrictive. this rule allows an origin
    server to provide, for a given response, a longer expiration time to
    an http/1.1 (or later) cache than to an http/1.0 cache. this might be
    useful if certain http/1.0 caches improperly calculate ages or
    expiration times, perhaps due to desynchronized clocks.

    many http/1.0 cache implementations will treat an expires value that
    is less than or equal to the response date value as being equivalent
    to the cache-control response directive "no-cache". if an http/1.1
    cache receives such a response, and the response does not include a
    cache-control header field, it should consider the response to be
    non-cacheable in order to retain compatibility with http/1.0 servers.

    note: an origin server might wish to use a relatively new http
    cache control feature, such as the "private" directive, on a
    network including older caches that do not understand that
    feature. the origin server will need to combine the new feature
    with an expires field whose value is less than or equal to the
    date value. this will prevent older caches from improperly
    caching the response.
hesabın var mı? giriş yap