idnits 2.17.1 draft-ietf-httpbis-p1-messaging-22.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- -- The draft header indicates that this document obsoletes RFC2616, but the abstract doesn't seem to mention this, which it should. -- The draft header indicates that this document obsoletes RFC2145, but the abstract doesn't seem to mention this, which it should. -- The draft header indicates that this document updates RFC2817, but the abstract doesn't seem to mention this, which it should. -- The draft header indicates that this document updates RFC2818, but the abstract doesn't seem to mention this, which it should. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year (Using the creation date from RFC2817, updated by this document, for RFC5378 checks: 1998-11-18) (Using the creation date from RFC2818, updated by this document, for RFC5378 checks: 1998-01-27) -- The document seems to contain a disclaimer for pre-RFC5378 work, and may have content which was first submitted before 10 November 2008. The disclaimer is necessary when there are original authors that you have been unable to contact, or if some do not wish to grant the BCP78 rights to the IETF Trust. If you are able to get all authors (current and original) to grant those rights, you can and should remove the disclaimer; otherwise, the disclaimer is needed and you can ignore this comment. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (February 23, 2013) is 4073 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Unused Reference: 'Part5' is defined on line 3040, but no explicit reference was found in the text == Unused Reference: 'Part7' is defined on line 3050, but no explicit reference was found in the text == Unused Reference: 'RFC2145' is defined on line 3123, but no explicit reference was found in the text == Outdated reference: A later version (-26) exists of draft-ietf-httpbis-p2-semantics-22 == Outdated reference: A later version (-26) exists of draft-ietf-httpbis-p4-conditional-22 == Outdated reference: A later version (-26) exists of draft-ietf-httpbis-p5-range-22 == Outdated reference: A later version (-26) exists of draft-ietf-httpbis-p6-cache-22 == Outdated reference: A later version (-26) exists of draft-ietf-httpbis-p7-auth-22 ** Downref: Normative reference to an Informational RFC: RFC 1950 ** Downref: Normative reference to an Informational RFC: RFC 1951 ** Downref: Normative reference to an Informational RFC: RFC 1952 -- Possible downref: Non-RFC (?) normative reference: ref. 'USASCII' -- Obsolete informational reference (is this intentional?): RFC 4395 (ref. 'BCP115') (Obsoleted by RFC 7595) -- Obsolete informational reference (is this intentional?): RFC 2068 (Obsoleted by RFC 2616) -- Obsolete informational reference (is this intentional?): RFC 2145 (Obsoleted by RFC 7230) -- Obsolete informational reference (is this intentional?): RFC 2616 (Obsoleted by RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235) -- Obsolete informational reference (is this intentional?): RFC 2818 (Obsoleted by RFC 9110) -- Obsolete informational reference (is this intentional?): RFC 5226 (Obsoleted by RFC 8126) -- Obsolete informational reference (is this intentional?): RFC 5246 (Obsoleted by RFC 8446) Summary: 3 errors (**), 0 flaws (~~), 9 warnings (==), 15 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 HTTPbis Working Group R. Fielding, Ed. 3 Internet-Draft Adobe 4 Obsoletes: 2145,2616 (if approved) J. Reschke, Ed. 5 Updates: 2817,2818 (if approved) greenbytes 6 Intended status: Standards Track February 23, 2013 7 Expires: August 27, 2013 9 Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing 10 draft-ietf-httpbis-p1-messaging-22 12 Abstract 14 The Hypertext Transfer Protocol (HTTP) is an application-level 15 protocol for distributed, collaborative, hypertext information 16 systems. HTTP has been in use by the World Wide Web global 17 information initiative since 1990. This document provides an 18 overview of HTTP architecture and its associated terminology, defines 19 the "http" and "https" Uniform Resource Identifier (URI) schemes, 20 defines the HTTP/1.1 message syntax and parsing requirements, and 21 describes general security concerns for implementations. 23 Editorial Note (To be removed by RFC Editor) 25 Discussion of this draft takes place on the HTTPBIS working group 26 mailing list (ietf-http-wg@w3.org), which is archived at 27 . 29 The current issues list is at 30 and related 31 documents (including fancy diffs) can be found at 32 . 34 The changes in this draft are summarized in Appendix D.2. 36 Status of This Memo 38 This Internet-Draft is submitted in full conformance with the 39 provisions of BCP 78 and BCP 79. 41 Internet-Drafts are working documents of the Internet Engineering 42 Task Force (IETF). Note that other groups may also distribute 43 working documents as Internet-Drafts. The list of current Internet- 44 Drafts is at http://datatracker.ietf.org/drafts/current/. 46 Internet-Drafts are draft documents valid for a maximum of six months 47 and may be updated, replaced, or obsoleted by other documents at any 48 time. It is inappropriate to use Internet-Drafts as reference 49 material or to cite them other than as "work in progress." 51 This Internet-Draft will expire on August 27, 2013. 53 Copyright Notice 55 Copyright (c) 2013 IETF Trust and the persons identified as the 56 document authors. All rights reserved. 58 This document is subject to BCP 78 and the IETF Trust's Legal 59 Provisions Relating to IETF Documents 60 (http://trustee.ietf.org/license-info) in effect on the date of 61 publication of this document. Please review these documents 62 carefully, as they describe your rights and restrictions with respect 63 to this document. Code Components extracted from this document must 64 include Simplified BSD License text as described in Section 4.e of 65 the Trust Legal Provisions and are provided without warranty as 66 described in the Simplified BSD License. 68 This document may contain material from IETF Documents or IETF 69 Contributions published or made publicly available before November 70 10, 2008. The person(s) controlling the copyright in some of this 71 material may not have granted the IETF Trust the right to allow 72 modifications of such material outside the IETF Standards Process. 73 Without obtaining an adequate license from the person(s) controlling 74 the copyright in such materials, this document may not be modified 75 outside the IETF Standards Process, and derivative works of it may 76 not be created outside the IETF Standards Process, except to format 77 it for publication as an RFC or to translate it into languages other 78 than English. 80 Table of Contents 82 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 5 83 1.1. Requirement Notation . . . . . . . . . . . . . . . . . . . 6 84 1.2. Syntax Notation . . . . . . . . . . . . . . . . . . . . . 6 85 2. Architecture . . . . . . . . . . . . . . . . . . . . . . . . . 6 86 2.1. Client/Server Messaging . . . . . . . . . . . . . . . . . 7 87 2.2. Implementation Diversity . . . . . . . . . . . . . . . . . 8 88 2.3. Intermediaries . . . . . . . . . . . . . . . . . . . . . . 9 89 2.4. Caches . . . . . . . . . . . . . . . . . . . . . . . . . . 11 90 2.5. Conformance and Error Handling . . . . . . . . . . . . . . 12 91 2.6. Protocol Versioning . . . . . . . . . . . . . . . . . . . 13 92 2.7. Uniform Resource Identifiers . . . . . . . . . . . . . . . 15 93 2.7.1. http URI scheme . . . . . . . . . . . . . . . . . . . 16 94 2.7.2. https URI scheme . . . . . . . . . . . . . . . . . . . 17 95 2.7.3. http and https URI Normalization and Comparison . . . 18 96 3. Message Format . . . . . . . . . . . . . . . . . . . . . . . . 19 97 3.1. Start Line . . . . . . . . . . . . . . . . . . . . . . . . 19 98 3.1.1. Request Line . . . . . . . . . . . . . . . . . . . . . 20 99 3.1.2. Status Line . . . . . . . . . . . . . . . . . . . . . 21 100 3.2. Header Fields . . . . . . . . . . . . . . . . . . . . . . 22 101 3.2.1. Field Extensibility . . . . . . . . . . . . . . . . . 22 102 3.2.2. Field Order . . . . . . . . . . . . . . . . . . . . . 22 103 3.2.3. Whitespace . . . . . . . . . . . . . . . . . . . . . . 23 104 3.2.4. Field Parsing . . . . . . . . . . . . . . . . . . . . 24 105 3.2.5. Field Limits . . . . . . . . . . . . . . . . . . . . . 25 106 3.2.6. Field value components . . . . . . . . . . . . . . . . 25 107 3.3. Message Body . . . . . . . . . . . . . . . . . . . . . . . 26 108 3.3.1. Transfer-Encoding . . . . . . . . . . . . . . . . . . 27 109 3.3.2. Content-Length . . . . . . . . . . . . . . . . . . . . 28 110 3.3.3. Message Body Length . . . . . . . . . . . . . . . . . 30 111 3.4. Handling Incomplete Messages . . . . . . . . . . . . . . . 32 112 3.5. Message Parsing Robustness . . . . . . . . . . . . . . . . 33 113 4. Transfer Codings . . . . . . . . . . . . . . . . . . . . . . . 33 114 4.1. Chunked Transfer Coding . . . . . . . . . . . . . . . . . 34 115 4.1.1. Trailer . . . . . . . . . . . . . . . . . . . . . . . 35 116 4.1.2. Decoding chunked . . . . . . . . . . . . . . . . . . . 36 117 4.2. Compression Codings . . . . . . . . . . . . . . . . . . . 37 118 4.2.1. Compress Coding . . . . . . . . . . . . . . . . . . . 37 119 4.2.2. Deflate Coding . . . . . . . . . . . . . . . . . . . . 37 120 4.2.3. Gzip Coding . . . . . . . . . . . . . . . . . . . . . 37 121 4.3. TE . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 122 5. Message Routing . . . . . . . . . . . . . . . . . . . . . . . 38 123 5.1. Identifying a Target Resource . . . . . . . . . . . . . . 38 124 5.2. Connecting Inbound . . . . . . . . . . . . . . . . . . . . 39 125 5.3. Request Target . . . . . . . . . . . . . . . . . . . . . . 39 126 5.4. Host . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 127 5.5. Effective Request URI . . . . . . . . . . . . . . . . . . 43 128 5.6. Associating a Response to a Request . . . . . . . . . . . 44 129 5.7. Message Forwarding . . . . . . . . . . . . . . . . . . . . 44 130 5.7.1. Via . . . . . . . . . . . . . . . . . . . . . . . . . 45 131 5.7.2. Transformations . . . . . . . . . . . . . . . . . . . 46 132 6. Connection Management . . . . . . . . . . . . . . . . . . . . 47 133 6.1. Connection . . . . . . . . . . . . . . . . . . . . . . . . 48 134 6.2. Establishment . . . . . . . . . . . . . . . . . . . . . . 49 135 6.3. Persistence . . . . . . . . . . . . . . . . . . . . . . . 49 136 6.3.1. Retrying Requests . . . . . . . . . . . . . . . . . . 50 137 6.3.2. Pipelining . . . . . . . . . . . . . . . . . . . . . . 51 138 6.4. Concurrency . . . . . . . . . . . . . . . . . . . . . . . 52 139 6.5. Failures and Time-outs . . . . . . . . . . . . . . . . . . 52 140 6.6. Tear-down . . . . . . . . . . . . . . . . . . . . . . . . 53 141 6.7. Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . 54 142 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 55 143 7.1. Header Field Registration . . . . . . . . . . . . . . . . 55 144 7.2. URI Scheme Registration . . . . . . . . . . . . . . . . . 56 145 7.3. Internet Media Type Registration . . . . . . . . . . . . . 56 146 7.3.1. Internet Media Type message/http . . . . . . . . . . . 57 147 7.3.2. Internet Media Type application/http . . . . . . . . . 58 148 7.4. Transfer Coding Registry . . . . . . . . . . . . . . . . . 59 149 7.5. Transfer Coding Registration . . . . . . . . . . . . . . . 59 150 7.6. Upgrade Token Registry . . . . . . . . . . . . . . . . . . 60 151 7.7. Upgrade Token Registration . . . . . . . . . . . . . . . . 61 152 8. Security Considerations . . . . . . . . . . . . . . . . . . . 61 153 8.1. DNS-related Attacks . . . . . . . . . . . . . . . . . . . 61 154 8.2. Intermediaries and Caching . . . . . . . . . . . . . . . . 61 155 8.3. Buffer Overflows . . . . . . . . . . . . . . . . . . . . . 62 156 8.4. Message Integrity . . . . . . . . . . . . . . . . . . . . 62 157 8.5. Server Log Information . . . . . . . . . . . . . . . . . . 63 158 9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 63 159 10. References . . . . . . . . . . . . . . . . . . . . . . . . . . 65 160 10.1. Normative References . . . . . . . . . . . . . . . . . . . 65 161 10.2. Informative References . . . . . . . . . . . . . . . . . . 66 162 Appendix A. HTTP Version History . . . . . . . . . . . . . . . . 68 163 A.1. Changes from HTTP/1.0 . . . . . . . . . . . . . . . . . . 69 164 A.1.1. Multi-homed Web Servers . . . . . . . . . . . . . . . 69 165 A.1.2. Keep-Alive Connections . . . . . . . . . . . . . . . . 69 166 A.1.3. Introduction of Transfer-Encoding . . . . . . . . . . 70 167 A.2. Changes from RFC 2616 . . . . . . . . . . . . . . . . . . 70 168 Appendix B. ABNF list extension: #rule . . . . . . . . . . . . . 72 169 Appendix C. Collected ABNF . . . . . . . . . . . . . . . . . . . 73 170 Appendix D. Change Log (to be removed by RFC Editor before 171 publication) . . . . . . . . . . . . . . . . . . . . 76 172 D.1. Since RFC 2616 . . . . . . . . . . . . . . . . . . . . . . 76 173 D.2. Since draft-ietf-httpbis-p1-messaging-21 . . . . . . . . . 76 174 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 176 1. Introduction 178 The Hypertext Transfer Protocol (HTTP) is an application-level 179 request/response protocol that uses extensible semantics and self- 180 descriptive message payloads for flexible interaction with network- 181 based hypertext information systems. This document is the first in a 182 series of documents that collectively form the HTTP/1.1 183 specification: 185 RFC xxx1: Message Syntax and Routing 187 RFC xxx2: Semantics and Content 189 RFC xxx3: Conditional Requests 191 RFC xxx4: Range Requests 193 RFC xxx5: Caching 195 RFC xxx6: Authentication 197 This HTTP/1.1 specification obsoletes and moves to historic status 198 RFC 2616, its predecessor RFC 2068, and RFC 2145 (on HTTP 199 versioning). This specification also updates the use of CONNECT to 200 establish a tunnel, previously defined in RFC 2817, and defines the 201 "https" URI scheme that was described informally in RFC 2818. 203 HTTP is a generic interface protocol for information systems. It is 204 designed to hide the details of how a service is implemented by 205 presenting a uniform interface to clients that is independent of the 206 types of resources provided. Likewise, servers do not need to be 207 aware of each client's purpose: an HTTP request can be considered in 208 isolation rather than being associated with a specific type of client 209 or a predetermined sequence of application steps. The result is a 210 protocol that can be used effectively in many different contexts and 211 for which implementations can evolve independently over time. 213 HTTP is also designed for use as an intermediation protocol for 214 translating communication to and from non-HTTP information systems. 215 HTTP proxies and gateways can provide access to alternative 216 information services by translating their diverse protocols into a 217 hypertext format that can be viewed and manipulated by clients in the 218 same way as HTTP services. 220 One consequence of this flexibility is that the protocol cannot be 221 defined in terms of what occurs behind the interface. Instead, we 222 are limited to defining the syntax of communication, the intent of 223 received communication, and the expected behavior of recipients. If 224 the communication is considered in isolation, then successful actions 225 ought to be reflected in corresponding changes to the observable 226 interface provided by servers. However, since multiple clients might 227 act in parallel and perhaps at cross-purposes, we cannot require that 228 such changes be observable beyond the scope of a single response. 230 This document describes the architectural elements that are used or 231 referred to in HTTP, defines the "http" and "https" URI schemes, 232 describes overall network operation and connection management, and 233 defines HTTP message framing and forwarding requirements. Our goal 234 is to define all of the mechanisms necessary for HTTP message 235 handling that are independent of message semantics, thereby defining 236 the complete set of requirements for message parsers and message- 237 forwarding intermediaries. 239 1.1. Requirement Notation 241 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 242 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 243 document are to be interpreted as described in [RFC2119]. 245 Conformance criteria and considerations regarding error handling are 246 defined in Section 2.5. 248 1.2. Syntax Notation 250 This specification uses the Augmented Backus-Naur Form (ABNF) 251 notation of [RFC5234] with the list rule extension defined in 252 Appendix B. Appendix C shows the collected ABNF with the list rule 253 expanded. 255 The following core rules are included by reference, as defined in 256 [RFC5234], Appendix B.1: ALPHA (letters), CR (carriage return), CRLF 257 (CR LF), CTL (controls), DIGIT (decimal 0-9), DQUOTE (double quote), 258 HEXDIG (hexadecimal 0-9/A-F/a-f), HTAB (horizontal tab), LF (line 259 feed), OCTET (any 8-bit sequence of data), SP (space), and VCHAR (any 260 visible [USASCII] character). 262 As a convention, ABNF rule names prefixed with "obs-" denote 263 "obsolete" grammar rules that appear for historical reasons. 265 2. Architecture 267 HTTP was created for the World Wide Web architecture and has evolved 268 over time to support the scalability needs of a worldwide hypertext 269 system. Much of that architecture is reflected in the terminology 270 and syntax productions used to define HTTP. 272 2.1. Client/Server Messaging 274 HTTP is a stateless request/response protocol that operates by 275 exchanging messages (Section 3) across a reliable transport or 276 session-layer "connection" (Section 6). An HTTP "client" is a 277 program that establishes a connection to a server for the purpose of 278 sending one or more HTTP requests. An HTTP "server" is a program 279 that accepts connections in order to service HTTP requests by sending 280 HTTP responses. 282 The terms client and server refer only to the roles that these 283 programs perform for a particular connection. The same program might 284 act as a client on some connections and a server on others. We use 285 the term "user agent" to refer to any of the various client programs 286 that initiate a request, including (but not limited to) browsers, 287 spiders (web-based robots), command-line tools, native applications, 288 and mobile apps. The term "origin server" is used to refer to the 289 program that can originate authoritative responses to a request. For 290 general requirements, we use the terms "sender" and "recipient" to 291 refer to any component that sends or receives, respectively, a given 292 message. 294 HTTP relies upon the Uniform Resource Identifier (URI) standard 295 [RFC3986] to indicate the target resource (Section 5.1) and 296 relationships between resources. Messages are passed in a format 297 similar to that used by Internet mail [RFC5322] and the Multipurpose 298 Internet Mail Extensions (MIME) [RFC2045] (see Appendix A of [Part2] 299 for the differences between HTTP and MIME messages). 301 Most HTTP communication consists of a retrieval request (GET) for a 302 representation of some resource identified by a URI. In the simplest 303 case, this might be accomplished via a single bidirectional 304 connection (===) between the user agent (UA) and the origin server 305 (O). 307 request > 308 UA ======================================= O 309 < response 311 A client sends an HTTP request to a server in the form of a request 312 message, beginning with a request-line that includes a method, URI, 313 and protocol version (Section 3.1.1), followed by header fields 314 containing request modifiers, client information, and representation 315 metadata (Section 3.2), an empty line to indicate the end of the 316 header section, and finally a message body containing the payload 317 body (if any, Section 3.3). 319 A server responds to a client's request by sending one or more HTTP 320 response messages, each beginning with a status line that includes 321 the protocol version, a success or error code, and textual reason 322 phrase (Section 3.1.2), possibly followed by header fields containing 323 server information, resource metadata, and representation metadata 324 (Section 3.2), an empty line to indicate the end of the header 325 section, and finally a message body containing the payload body (if 326 any, Section 3.3). 328 A connection might be used for multiple request/response exchanges, 329 as defined in Section 6.3. 331 The following example illustrates a typical message exchange for a 332 GET request on the URI "http://www.example.com/hello.txt": 334 client request: 336 GET /hello.txt HTTP/1.1 337 User-Agent: curl/7.16.3 libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3 338 Host: www.example.com 339 Accept-Language: en, mi 341 server response: 343 HTTP/1.1 200 OK 344 Date: Mon, 27 Jul 2009 12:28:53 GMT 345 Server: Apache 346 Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT 347 ETag: "34aa387-d-1568eb00" 348 Accept-Ranges: bytes 349 Content-Length: 14 350 Vary: Accept-Encoding 351 Content-Type: text/plain 353 Hello World! 355 (Note that the content length includes the trailing CR/LF sequence of 356 the body text) 358 2.2. Implementation Diversity 360 When considering the design of HTTP, it is easy to fall into a trap 361 of thinking that all user agents are general-purpose browsers and all 362 origin servers are large public websites. That is not the case in 363 practice. Common HTTP user agents include household appliances, 364 stereos, scales, firmware update scripts, command-line programs, 365 mobile apps, and communication devices in a multitude of shapes and 366 sizes. Likewise, common HTTP origin servers include home automation 367 units, configurable networking components, office machines, 368 autonomous robots, news feeds, traffic cameras, ad selectors, and 369 video delivery platforms. 371 The term "user agent" does not imply that there is a human user 372 directly interacting with the software agent at the time of a 373 request. In many cases, a user agent is installed or configured to 374 run in the background and save its results for later inspection (or 375 save only a subset of those results that might be interesting or 376 erroneous). Spiders, for example, are typically given a start URI 377 and configured to follow certain behavior while crawling the Web as a 378 hypertext graph. 380 The implementation diversity of HTTP means that we cannot assume the 381 user agent can make interactive suggestions to a user or provide 382 adequate warning for security or privacy options. In the few cases 383 where this specification requires reporting of errors to the user, it 384 is acceptable for such reporting to only be observable in an error 385 console or log file. Likewise, requirements that an automated action 386 be confirmed by the user before proceeding can be met via advance 387 configuration choices, run-time options, or simply not proceeding 388 with the unsafe action. 390 2.3. Intermediaries 392 HTTP enables the use of intermediaries to satisfy requests through a 393 chain of connections. There are three common forms of HTTP 394 intermediary: proxy, gateway, and tunnel. In some cases, a single 395 intermediary might act as an origin server, proxy, gateway, or 396 tunnel, switching behavior based on the nature of each request. 398 > > > > 399 UA =========== A =========== B =========== C =========== O 400 < < < < 402 The figure above shows three intermediaries (A, B, and C) between the 403 user agent and origin server. A request or response message that 404 travels the whole chain will pass through four separate connections. 405 Some HTTP communication options might apply only to the connection 406 with the nearest, non-tunnel neighbor, only to the end-points of the 407 chain, or to all connections along the chain. Although the diagram 408 is linear, each participant might be engaged in multiple, 409 simultaneous communications. For example, B might be receiving 410 requests from many clients other than A, and/or forwarding requests 411 to servers other than C, at the same time that it is handling A's 412 request. 414 We use the terms "upstream" and "downstream" to describe various 415 requirements in relation to the directional flow of a message: all 416 messages flow from upstream to downstream. Likewise, we use the 417 terms inbound and outbound to refer to directions in relation to the 418 request path: "inbound" means toward the origin server and "outbound" 419 means toward the user agent. 421 A "proxy" is a message forwarding agent that is selected by the 422 client, usually via local configuration rules, to receive requests 423 for some type(s) of absolute URI and attempt to satisfy those 424 requests via translation through the HTTP interface. Some 425 translations are minimal, such as for proxy requests for "http" URIs, 426 whereas other requests might require translation to and from entirely 427 different application-level protocols. Proxies are often used to 428 group an organization's HTTP requests through a common intermediary 429 for the sake of security, annotation services, or shared caching. 431 An HTTP-to-HTTP proxy is called a "transforming proxy" if it is 432 designed or configured to modify request or response messages in a 433 semantically meaningful way (i.e., modifications, beyond those 434 required by normal HTTP processing, that change the message in a way 435 that would be significant to the original sender or potentially 436 significant to downstream recipients). For example, a transforming 437 proxy might be acting as a shared annotation server (modifying 438 responses to include references to a local annotation database), a 439 malware filter, a format transcoder, or an intranet-to-Internet 440 privacy filter. Such transformations are presumed to be desired by 441 the client (or client organization) that selected the proxy and are 442 beyond the scope of this specification. However, when a proxy is not 443 intended to transform a given message, we use the term "non- 444 transforming proxy" to target requirements that preserve HTTP message 445 semantics. See Section 6.3.4 of [Part2] and Section 7.5 of [Part6] 446 for status and warning codes related to transformations. 448 A "gateway" (a.k.a., "reverse proxy") is a receiving agent that acts 449 as a layer above some other server(s) and translates the received 450 requests to the underlying server's protocol. Gateways are often 451 used to encapsulate legacy or untrusted information services, to 452 improve server performance through "accelerator" caching, and to 453 enable partitioning or load-balancing of HTTP services across 454 multiple machines. 456 A gateway behaves as an origin server on its outbound connection and 457 as a user agent on its inbound connection. All HTTP requirements 458 applicable to an origin server also apply to the outbound 459 communication of a gateway. A gateway communicates with inbound 460 servers using any protocol that it desires, including private 461 extensions to HTTP that are outside the scope of this specification. 462 However, an HTTP-to-HTTP gateway that wishes to interoperate with 463 third-party HTTP servers MUST conform to HTTP user agent requirements 464 on the gateway's inbound connection and MUST implement the Connection 465 (Section 6.1) and Via (Section 5.7.1) header fields for both 466 connections. 468 A "tunnel" acts as a blind relay between two connections without 469 changing the messages. Once active, a tunnel is not considered a 470 party to the HTTP communication, though the tunnel might have been 471 initiated by an HTTP request. A tunnel ceases to exist when both 472 ends of the relayed connection are closed. Tunnels are used to 473 extend a virtual connection through an intermediary, such as when 474 Transport Layer Security (TLS, [RFC5246]) is used to establish 475 confidential communication through a shared firewall proxy. 477 The above categories for intermediary only consider those acting as 478 participants in the HTTP communication. There are also 479 intermediaries that can act on lower layers of the network protocol 480 stack, filtering or redirecting HTTP traffic without the knowledge or 481 permission of message senders. Network intermediaries often 482 introduce security flaws or interoperability problems by violating 483 HTTP semantics. For example, an "interception proxy" [RFC3040] (also 484 commonly known as a "transparent proxy" [RFC1919] or "captive 485 portal") differs from an HTTP proxy because it is not selected by the 486 client. Instead, an interception proxy filters or redirects outgoing 487 TCP port 80 packets (and occasionally other common port traffic). 488 Interception proxies are commonly found on public network access 489 points, as a means of enforcing account subscription prior to 490 allowing use of non-local Internet services, and within corporate 491 firewalls to enforce network usage policies. They are 492 indistinguishable from a man-in-the-middle attack. 494 HTTP is defined as a stateless protocol, meaning that each request 495 message can be understood in isolation. Many implementations depend 496 on HTTP's stateless design in order to reuse proxied connections or 497 dynamically load-balance requests across multiple servers. Hence, 498 servers MUST NOT assume that two requests on the same connection are 499 from the same user agent unless the connection is secured and 500 specific to that agent. Some non-standard HTTP extensions (e.g., 501 [RFC4559]) have been known to violate this requirement, resulting in 502 security and interoperability problems. 504 2.4. Caches 506 A "cache" is a local store of previous response messages and the 507 subsystem that controls its message storage, retrieval, and deletion. 508 A cache stores cacheable responses in order to reduce the response 509 time and network bandwidth consumption on future, equivalent 510 requests. Any client or server MAY employ a cache, though a cache 511 cannot be used by a server while it is acting as a tunnel. 513 The effect of a cache is that the request/response chain is shortened 514 if one of the participants along the chain has a cached response 515 applicable to that request. The following illustrates the resulting 516 chain if B has a cached copy of an earlier response from O (via C) 517 for a request that has not been cached by UA or A. 519 > > 520 UA =========== A =========== B - - - - - - C - - - - - - O 521 < < 523 A response is "cacheable" if a cache is allowed to store a copy of 524 the response message for use in answering subsequent requests. Even 525 when a response is cacheable, there might be additional constraints 526 placed by the client or by the origin server on when that cached 527 response can be used for a particular request. HTTP requirements for 528 cache behavior and cacheable responses are defined in Section 2 of 529 [Part6]. 531 There are a wide variety of architectures and configurations of 532 caches deployed across the World Wide Web and inside large 533 organizations. These include national hierarchies of proxy caches to 534 save transoceanic bandwidth, collaborative systems that broadcast or 535 multicast cache entries, archives of pre-fetched cache entries for 536 use in off-line or high-latency environments, and so on. 538 2.5. Conformance and Error Handling 540 This specification targets conformance criteria according to the role 541 of a participant in HTTP communication. Hence, HTTP requirements are 542 placed on senders, recipients, clients, servers, user agents, 543 intermediaries, origin servers, proxies, gateways, or caches, 544 depending on what behavior is being constrained by the requirement. 545 Additional (social) requirements are placed on implementations, 546 resource owners, and protocol element registrations when they apply 547 beyond the scope of a single communication. 549 The verb "generate" is used instead of "send" where a requirement 550 differentiates between creating a protocol element and merely 551 forwarding a received element downstream. 553 An implementation is considered conformant if it complies with all of 554 the requirements associated with the roles it partakes in HTTP. Note 555 that SHOULD-level requirements are relevant here, unless one of the 556 documented exceptions is applicable. 558 Conformance applies to both the syntax and semantics of HTTP protocol 559 elements. A sender MUST NOT generate protocol elements that convey a 560 meaning that is known by that sender to be false. A sender MUST NOT 561 generate protocol elements that do not match the grammar defined by 562 the ABNF rules for those protocol elements that are applicable to the 563 sender's role. If a received protocol element is processed, the 564 recipient MUST be able to parse any value that would match the ABNF 565 rules for that protocol element, excluding only those rules not 566 applicable to the recipient's role. 568 Unless noted otherwise, a recipient MAY attempt to recover a usable 569 protocol element from an invalid construct. HTTP does not define 570 specific error handling mechanisms except when they have a direct 571 impact on security, since different applications of the protocol 572 require different error handling strategies. For example, a Web 573 browser might wish to transparently recover from a response where the 574 Location header field doesn't parse according to the ABNF, whereas a 575 systems control client might consider any form of error recovery to 576 be dangerous. 578 2.6. Protocol Versioning 580 HTTP uses a "." numbering scheme to indicate versions 581 of the protocol. This specification defines version "1.1". The 582 protocol version as a whole indicates the sender's conformance with 583 the set of requirements laid out in that version's corresponding 584 specification of HTTP. 586 The version of an HTTP message is indicated by an HTTP-version field 587 in the first line of the message. HTTP-version is case-sensitive. 589 HTTP-version = HTTP-name "/" DIGIT "." DIGIT 590 HTTP-name = %x48.54.54.50 ; "HTTP", case-sensitive 592 The HTTP version number consists of two decimal digits separated by a 593 "." (period or decimal point). The first digit ("major version") 594 indicates the HTTP messaging syntax, whereas the second digit ("minor 595 version") indicates the highest minor version to which the sender is 596 conformant and able to understand for future communication. The 597 minor version advertises the sender's communication capabilities even 598 when the sender is only using a backwards-compatible subset of the 599 protocol, thereby letting the recipient know that more advanced 600 features can be used in response (by servers) or in future requests 601 (by clients). 603 When an HTTP/1.1 message is sent to an HTTP/1.0 recipient [RFC1945] 604 or a recipient whose version is unknown, the HTTP/1.1 message is 605 constructed such that it can be interpreted as a valid HTTP/1.0 606 message if all of the newer features are ignored. This specification 607 places recipient-version requirements on some new features so that a 608 conformant sender will only use compatible features until it has 609 determined, through configuration or the receipt of a message, that 610 the recipient supports HTTP/1.1. 612 The interpretation of a header field does not change between minor 613 versions of the same major HTTP version, though the default behavior 614 of a recipient in the absence of such a field can change. Unless 615 specified otherwise, header fields defined in HTTP/1.1 are defined 616 for all versions of HTTP/1.x. In particular, the Host and Connection 617 header fields ought to be implemented by all HTTP/1.x implementations 618 whether or not they advertise conformance with HTTP/1.1. 620 New header fields can be defined such that, when they are understood 621 by a recipient, they might override or enhance the interpretation of 622 previously defined header fields. When an implementation receives an 623 unrecognized header field, the recipient MUST ignore that header 624 field for local processing regardless of the message's HTTP version. 625 An unrecognized header field received by a proxy MUST be forwarded 626 downstream unless the header field's field-name is listed in the 627 message's Connection header field (see Section 6.1). These 628 requirements allow HTTP's functionality to be enhanced without 629 requiring prior update of deployed intermediaries. 631 Intermediaries that process HTTP messages (i.e., all intermediaries 632 other than those acting as tunnels) MUST send their own HTTP-version 633 in forwarded messages. In other words, they MUST NOT blindly forward 634 the first line of an HTTP message without ensuring that the protocol 635 version in that message matches a version to which that intermediary 636 is conformant for both the receiving and sending of messages. 637 Forwarding an HTTP message without rewriting the HTTP-version might 638 result in communication errors when downstream recipients use the 639 message sender's version to determine what features are safe to use 640 for later communication with that sender. 642 An HTTP client SHOULD send a request version equal to the highest 643 version to which the client is conformant and whose major version is 644 no higher than the highest version supported by the server, if this 645 is known. An HTTP client MUST NOT send a version to which it is not 646 conformant. 648 An HTTP client MAY send a lower request version if it is known that 649 the server incorrectly implements the HTTP specification, but only 650 after the client has attempted at least one normal request and 651 determined from the response status or header fields (e.g., Server) 652 that the server improperly handles higher request versions. 654 An HTTP server SHOULD send a response version equal to the highest 655 version to which the server is conformant and whose major version is 656 less than or equal to the one received in the request. An HTTP 657 server MUST NOT send a version to which it is not conformant. A 658 server MAY send a 505 (HTTP Version Not Supported) response if it 659 cannot send a response using the major version used in the client's 660 request. 662 An HTTP server MAY send an HTTP/1.0 response to an HTTP/1.0 request 663 if it is known or suspected that the client incorrectly implements 664 the HTTP specification and is incapable of correctly processing later 665 version responses, such as when a client fails to parse the version 666 number correctly or when an intermediary is known to blindly forward 667 the HTTP-version even when it doesn't conform to the given minor 668 version of the protocol. Such protocol downgrades SHOULD NOT be 669 performed unless triggered by specific client attributes, such as 670 when one or more of the request header fields (e.g., User-Agent) 671 uniquely match the values sent by a client known to be in error. 673 The intention of HTTP's versioning design is that the major number 674 will only be incremented if an incompatible message syntax is 675 introduced, and that the minor number will only be incremented when 676 changes made to the protocol have the effect of adding to the message 677 semantics or implying additional capabilities of the sender. 678 However, the minor version was not incremented for the changes 679 introduced between [RFC2068] and [RFC2616], and this revision has 680 specifically avoiding any such changes to the protocol. 682 2.7. Uniform Resource Identifiers 684 Uniform Resource Identifiers (URIs) [RFC3986] are used throughout 685 HTTP as the means for identifying resources (Section 2 of [Part2]). 686 URI references are used to target requests, indicate redirects, and 687 define relationships. 689 This specification adopts the definitions of "URI-reference", 690 "absolute-URI", "relative-part", "port", "host", "path-abempty", 691 "query", "segment", and "authority" from the URI generic syntax. In 692 addition, we define an "absolute-path" rule (that differs from RFC 693 3986's "path-absolute" in that it allows a leading "//") and a 694 "partial-URI" rule for protocol elements that allow a relative URI 695 but not a fragment. 697 URI-reference = 698 absolute-URI = 699 relative-part = 700 authority = 701 path-abempty = 702 port = 703 query = 704 segment = 705 uri-host = 707 absolute-path = 1*( "/" segment ) 708 partial-URI = relative-part [ "?" query ] 710 Each protocol element in HTTP that allows a URI reference will 711 indicate in its ABNF production whether the element allows any form 712 of reference (URI-reference), only a URI in absolute form (absolute- 713 URI), only the path and optional query components, or some 714 combination of the above. Unless otherwise indicated, URI references 715 are parsed relative to the effective request URI (Section 5.5). 717 2.7.1. http URI scheme 719 The "http" URI scheme is hereby defined for the purpose of minting 720 identifiers according to their association with the hierarchical 721 namespace governed by a potential HTTP origin server listening for 722 TCP connections on a given port. 724 http-URI = "http:" "//" authority path-abempty [ "?" query ] 726 The HTTP origin server is identified by the generic syntax's 727 authority component, which includes a host identifier and optional 728 TCP port ([RFC3986], Section 3.2.2). The remainder of the URI, 729 consisting of both the hierarchical path component and optional query 730 component, serves as an identifier for a potential resource within 731 that origin server's name space. 733 If the host identifier is provided as an IP address, then the origin 734 server is any listener on the indicated TCP port at that IP address. 735 If host is a registered name, then that name is considered an 736 indirect identifier and the recipient might use a name resolution 737 service, such as DNS, to find the address of a listener for that 738 host. The host MUST NOT be empty; if an "http" URI is received with 739 an empty host, then it MUST be rejected as invalid. If the port 740 subcomponent is empty or not given, then TCP port 80 is assumed (the 741 default reserved port for WWW services). 743 Regardless of the form of host identifier, access to that host is not 744 implied by the mere presence of its name or address. The host might 745 or might not exist and, even when it does exist, might or might not 746 be running an HTTP server or listening to the indicated port. The 747 "http" URI scheme makes use of the delegated nature of Internet names 748 and addresses to establish a naming authority (whatever entity has 749 the ability to place an HTTP server at that Internet name or address) 750 and allows that authority to determine which names are valid and how 751 they might be used. 753 When an "http" URI is used within a context that calls for access to 754 the indicated resource, a client MAY attempt access by resolving the 755 host to an IP address, establishing a TCP connection to that address 756 on the indicated port, and sending an HTTP request message 757 (Section 3) containing the URI's identifying data (Section 5) to the 758 server. If the server responds to that request with a non-interim 759 HTTP response message, as described in Section 6 of [Part2], then 760 that response is considered an authoritative answer to the client's 761 request. 763 Although HTTP is independent of the transport protocol, the "http" 764 scheme is specific to TCP-based services because the name delegation 765 process depends on TCP for establishing authority. An HTTP service 766 based on some other underlying connection protocol would presumably 767 be identified using a different URI scheme, just as the "https" 768 scheme (below) is used for resources that require an end-to-end 769 secured connection. Other protocols might also be used to provide 770 access to "http" identified resources -- it is only the authoritative 771 interface used for mapping the namespace that is specific to TCP. 773 The URI generic syntax for authority also includes a deprecated 774 userinfo subcomponent ([RFC3986], Section 3.2.1) for including user 775 authentication information in the URI. Some implementations make use 776 of the userinfo component for internal configuration of 777 authentication information, such as within command invocation 778 options, configuration files, or bookmark lists, even though such 779 usage might expose a user identifier or password. Senders MUST 780 exclude the userinfo subcomponent (and its "@" delimiter) when an 781 "http" URI is transmitted within a message as a request target or 782 header field value. Recipients of an "http" URI reference SHOULD 783 parse for userinfo and treat its presence as an error, since it is 784 likely being used to obscure the authority for the sake of phishing 785 attacks. 787 2.7.2. https URI scheme 789 The "https" URI scheme is hereby defined for the purpose of minting 790 identifiers according to their association with the hierarchical 791 namespace governed by a potential HTTP origin server listening to a 792 given TCP port for TLS-secured connections [RFC5246]. 794 All of the requirements listed above for the "http" scheme are also 795 requirements for the "https" scheme, except that a default TCP port 796 of 443 is assumed if the port subcomponent is empty or not given, and 797 the TCP connection MUST be secured, end-to-end, through the use of 798 strong encryption prior to sending the first HTTP request. 800 https-URI = "https:" "//" authority path-abempty [ "?" query ] 802 Resources made available via the "https" scheme have no shared 803 identity with the "http" scheme even if their resource identifiers 804 indicate the same authority (the same host listening to the same TCP 805 port). They are distinct name spaces and are considered to be 806 distinct origin servers. However, an extension to HTTP that is 807 defined to apply to entire host domains, such as the Cookie protocol 808 [RFC6265], can allow information set by one service to impact 809 communication with other services within a matching group of host 810 domains. 812 The process for authoritative access to an "https" identified 813 resource is defined in [RFC2818]. 815 2.7.3. http and https URI Normalization and Comparison 817 Since the "http" and "https" schemes conform to the URI generic 818 syntax, such URIs are normalized and compared according to the 819 algorithm defined in [RFC3986], Section 6, using the defaults 820 described above for each scheme. 822 If the port is equal to the default port for a scheme, the normal 823 form is to elide the port subcomponent. When not being used in 824 absolute form as the request target of an OPTIONS request, an empty 825 path component is equivalent to an absolute path of "/", so the 826 normal form is to provide a path of "/" instead. The scheme and host 827 are case-insensitive and normally provided in lowercase; all other 828 components are compared in a case-sensitive manner. Characters other 829 than those in the "reserved" set are equivalent to their percent- 830 encoded octets (see [RFC3986], Section 2.1): the normal form is to 831 not encode them. 833 For example, the following three URIs are equivalent: 835 http://example.com:80/~smith/home.html 836 http://EXAMPLE.com/%7Esmith/home.html 837 http://EXAMPLE.com:/%7esmith/home.html 839 3. Message Format 841 All HTTP/1.1 messages consist of a start-line followed by a sequence 842 of octets in a format similar to the Internet Message Format 843 [RFC5322]: zero or more header fields (collectively referred to as 844 the "headers" or the "header section"), an empty line indicating the 845 end of the header section, and an optional message body. 847 HTTP-message = start-line 848 *( header-field CRLF ) 849 CRLF 850 [ message-body ] 852 The normal procedure for parsing an HTTP message is to read the 853 start-line into a structure, read each header field into a hash table 854 by field name until the empty line, and then use the parsed data to 855 determine if a message body is expected. If a message body has been 856 indicated, then it is read as a stream until an amount of octets 857 equal to the message body length is read or the connection is closed. 859 Recipients MUST parse an HTTP message as a sequence of octets in an 860 encoding that is a superset of US-ASCII [USASCII]. Parsing an HTTP 861 message as a stream of Unicode characters, without regard for the 862 specific encoding, creates security vulnerabilities due to the 863 varying ways that string processing libraries handle invalid 864 multibyte character sequences that contain the octet LF (%x0A). 865 String-based parsers can only be safely used within protocol elements 866 after the element has been extracted from the message, such as within 867 a header field-value after message parsing has delineated the 868 individual fields. 870 An HTTP message can be parsed as a stream for incremental processing 871 or forwarding downstream. However, recipients cannot rely on 872 incremental delivery of partial messages, since some implementations 873 will buffer or delay message forwarding for the sake of network 874 efficiency, security checks, or payload transformations. 876 3.1. Start Line 878 An HTTP message can either be a request from client to server or a 879 response from server to client. Syntactically, the two types of 880 message differ only in the start-line, which is either a request-line 881 (for requests) or a status-line (for responses), and in the algorithm 882 for determining the length of the message body (Section 3.3). 884 In theory, a client could receive requests and a server could receive 885 responses, distinguishing them by their different start-line formats, 886 but in practice servers are implemented to only expect a request (a 887 response is interpreted as an unknown or invalid request method) and 888 clients are implemented to only expect a response. 890 start-line = request-line / status-line 892 A sender MUST NOT send whitespace between the start-line and the 893 first header field. The presence of such whitespace in a request 894 might be an attempt to trick a server into ignoring that field or 895 processing the line after it as a new request, either of which might 896 result in a security vulnerability if other implementations within 897 the request chain interpret the same message differently. Likewise, 898 the presence of such whitespace in a response might be ignored by 899 some clients or cause others to cease parsing. 901 A recipient that receives whitespace between the start-line and the 902 first header field MUST either reject the message as invalid or 903 consume each whitespace-preceded line without further processing of 904 it (i.e., ignore the entire line, along with any subsequent lines 905 preceded by whitespace, until a properly formed header field is 906 received or the header block is terminated). 908 3.1.1. Request Line 910 A request-line begins with a method token, followed by a single space 911 (SP), the request-target, another single space (SP), the protocol 912 version, and ending with CRLF. 914 request-line = method SP request-target SP HTTP-version CRLF 916 The method token indicates the request method to be performed on the 917 target resource. The request method is case-sensitive. 919 method = token 921 The methods defined by this specification can be found in Section 4 922 of [Part2], along with information regarding the HTTP method registry 923 and considerations for defining new methods. 925 The request-target identifies the target resource upon which to apply 926 the request, as defined in Section 5.3. 928 No whitespace is allowed inside the method, request-target, and 929 protocol version. Hence, recipients typically parse the request-line 930 into its component parts by splitting on whitespace (see 931 Section 3.5). 933 Unfortunately, some user agents fail to properly encode hypertext 934 references that have embedded whitespace, sending the characters 935 directly instead of properly encoding or excluding the disallowed 936 characters. Recipients of an invalid request-line SHOULD respond 937 with either a 400 (Bad Request) error or a 301 (Moved Permanently) 938 redirect with the request-target properly encoded. Recipients SHOULD 939 NOT attempt to autocorrect and then process the request without a 940 redirect, since the invalid request-line might be deliberately 941 crafted to bypass security filters along the request chain. 943 HTTP does not place a pre-defined limit on the length of a request- 944 line. A server that receives a method longer than any that it 945 implements SHOULD respond with a 501 (Not Implemented) status code. 946 A server MUST be prepared to receive URIs of unbounded length and 947 respond with the 414 (URI Too Long) status code if the received 948 request-target would be longer than the server wishes to handle (see 949 Section 6.5.12 of [Part2]). 951 Various ad-hoc limitations on request-line length are found in 952 practice. It is RECOMMENDED that all HTTP senders and recipients 953 support, at a minimum, request-line lengths of 8000 octets. 955 3.1.2. Status Line 957 The first line of a response message is the status-line, consisting 958 of the protocol version, a space (SP), the status code, another 959 space, a possibly-empty textual phrase describing the status code, 960 and ending with CRLF. 962 status-line = HTTP-version SP status-code SP reason-phrase CRLF 964 The status-code element is a 3-digit integer code describing the 965 result of the server's attempt to understand and satisfy the client's 966 corresponding request. The rest of the response message is to be 967 interpreted in light of the semantics defined for that status code. 968 See Section 6 of [Part2] for information about the semantics of 969 status codes, including the classes of status code (indicated by the 970 first digit), the status codes defined by this specification, 971 considerations for the definition of new status codes, and the IANA 972 registry. 974 status-code = 3DIGIT 976 The reason-phrase element exists for the sole purpose of providing a 977 textual description associated with the numeric status code, mostly 978 out of deference to earlier Internet application protocols that were 979 more frequently used with interactive text clients. A client SHOULD 980 ignore the reason-phrase content. 982 reason-phrase = *( HTAB / SP / VCHAR / obs-text ) 984 3.2. Header Fields 986 Each HTTP header field consists of a case-insensitive field name 987 followed by a colon (":"), optional whitespace, and the field value. 989 header-field = field-name ":" OWS field-value BWS 990 field-name = token 991 field-value = *( field-content / obs-fold ) 992 field-content = *( HTAB / SP / VCHAR / obs-text ) 993 obs-fold = CRLF ( SP / HTAB ) 994 ; obsolete line folding 995 ; see Section 3.2.4 997 The field-name token labels the corresponding field-value as having 998 the semantics defined by that header field. For example, the Date 999 header field is defined in Section 7.1.1.2 of [Part2] as containing 1000 the origination timestamp for the message in which it appears. 1002 3.2.1. Field Extensibility 1004 HTTP header fields are fully extensible: there is no limit on the 1005 introduction of new field names, each presumably defining new 1006 semantics, nor on the number of header fields used in a given 1007 message. Existing fields are defined in each part of this 1008 specification and in many other specifications outside the core 1009 standard. New header fields can be introduced without changing the 1010 protocol version if their defined semantics allow them to be safely 1011 ignored by recipients that do not recognize them. 1013 New HTTP header fields ought to be be registered with IANA in the 1014 Message Header Field Registry, as described in Section 8.3 of 1015 [Part2]. A proxy MUST forward unrecognized header fields unless the 1016 field-name is listed in the Connection header field (Section 6.1) or 1017 the proxy is specifically configured to block, or otherwise 1018 transform, such fields. Other recipients SHOULD ignore unrecognized 1019 header fields. 1021 3.2.2. Field Order 1023 The order in which header fields with differing field names are 1024 received is not significant. However, it is "good practice" to send 1025 header fields that contain control data first, such as Host on 1026 requests and Date on responses, so that implementations can decide 1027 when not to handle a message as early as possible. A server MUST 1028 wait until the entire header section is received before interpreting 1029 a request message, since later header fields might include 1030 conditionals, authentication credentials, or deliberately misleading 1031 duplicate header fields that would impact request processing. 1033 A sender MUST NOT generate multiple header fields with the same field 1034 name in a message unless either the entire field value for that 1035 header field is defined as a comma-separated list [i.e., #(values)] 1036 or the header field is a well-known exception (as noted below). 1038 Multiple header fields with the same field name can be combined into 1039 one "field-name: field-value" pair, without changing the semantics of 1040 the message, by appending each subsequent field value to the combined 1041 field value in order, separated by a comma. The order in which 1042 header fields with the same field name are received is therefore 1043 significant to the interpretation of the combined field value; a 1044 proxy MUST NOT change the order of these field values when forwarding 1045 a message. 1047 Note: In practice, the "Set-Cookie" header field ([RFC6265]) often 1048 appears multiple times in a response message and does not use the 1049 list syntax, violating the above requirements on multiple header 1050 fields with the same name. Since it cannot be combined into a 1051 single field-value, recipients ought to handle "Set-Cookie" as a 1052 special case while processing header fields. (See Appendix A.2.3 1053 of [Kri2001] for details.) 1055 3.2.3. Whitespace 1057 This specification uses three rules to denote the use of linear 1058 whitespace: OWS (optional whitespace), RWS (required whitespace), and 1059 BWS ("bad" whitespace). 1061 The OWS rule is used where zero or more linear whitespace octets 1062 might appear. OWS SHOULD either not be generated or be generated as 1063 a single SP. Multiple OWS octets that occur within field-content 1064 SHOULD either be replaced with a single SP or transformed to all SP 1065 octets (each octet other than SP replaced with SP) before 1066 interpreting the field value or forwarding the message downstream. 1068 RWS is used when at least one linear whitespace octet is required to 1069 separate field tokens. RWS SHOULD be generated as a single SP. 1070 Multiple RWS octets that occur within field-content SHOULD either be 1071 replaced with a single SP or transformed to all SP octets before 1072 interpreting the field value or forwarding the message downstream. 1074 BWS is used where the grammar allows optional whitespace, for 1075 historical reasons, but senders SHOULD NOT generate it in messages; 1076 recipients MUST accept such bad optional whitespace and remove it 1077 before interpreting the field value or forwarding the message 1078 downstream. 1080 OWS = *( SP / HTAB ) 1081 ; optional whitespace 1082 RWS = 1*( SP / HTAB ) 1083 ; required whitespace 1084 BWS = OWS 1085 ; "bad" whitespace 1087 3.2.4. Field Parsing 1089 No whitespace is allowed between the header field-name and colon. In 1090 the past, differences in the handling of such whitespace have led to 1091 security vulnerabilities in request routing and response handling. A 1092 server MUST reject any received request message that contains 1093 whitespace between a header field-name and colon with a response code 1094 of 400 (Bad Request). A proxy MUST remove any such whitespace from a 1095 response message before forwarding the message downstream. 1097 A field value is preceded by optional whitespace (OWS); a single SP 1098 is preferred. The field value does not include any leading or 1099 trailing white space: OWS occurring before the first non-whitespace 1100 octet of the field value or after the last non-whitespace octet of 1101 the field value is ignored and SHOULD be removed before further 1102 processing (as this does not change the meaning of the header field). 1104 Historically, HTTP header field values could be extended over 1105 multiple lines by preceding each extra line with at least one space 1106 or horizontal tab (obs-fold). This specification deprecates such 1107 line folding except within the message/http media type 1108 (Section 7.3.1). Senders MUST NOT generate messages that include 1109 line folding (i.e., that contain any field-value that contains a 1110 match to the obs-fold rule) unless the message is intended for 1111 packaging within the message/http media type. When an obs-fold is 1112 received in a message, recipients MUST do one of: 1114 o accept the message and replace any embedded obs-fold whitespace 1115 with either a single SP or a matching number of SP octets (to 1116 avoid buffer copying) prior to interpreting the field value or 1117 forwarding the message downstream; 1119 o if it is a request, reject the message by sending a 400 (Bad 1120 Request) response with a representation explaining that obsolete 1121 line folding is unacceptable; or, 1123 o if it is a response, discard the message and generate a 502 (Bad 1124 Gateway) response with a representation explaining that 1125 unacceptable line folding was received. 1127 Recipients that choose not to implement obs-fold processing (as 1128 described above) MUST NOT accept messages containing header fields 1129 with leading whitespace, as this can expose them to attacks that 1130 exploit this difference in processing. 1132 Historically, HTTP has allowed field content with text in the ISO- 1133 8859-1 [ISO-8859-1] charset, supporting other charsets only through 1134 use of [RFC2047] encoding. In practice, most HTTP header field 1135 values use only a subset of the US-ASCII charset [USASCII]. Newly 1136 defined header fields SHOULD limit their field values to US-ASCII 1137 octets. Recipients SHOULD treat other octets in field content (obs- 1138 text) as opaque data. 1140 3.2.5. Field Limits 1142 HTTP does not place a pre-defined limit on the length of each header 1143 field or on the length of the header block as a whole. Various ad- 1144 hoc limitations on individual header field length are found in 1145 practice, often depending on the specific field semantics. 1147 A server MUST be prepared to receive request header fields of 1148 unbounded length and respond with an appropriate 4xx (Client Error) 1149 status code if the received header field(s) are larger than the 1150 server wishes to process. 1152 A client MUST be prepared to receive response header fields of 1153 unbounded length. A client MAY discard or truncate received header 1154 fields that are larger than the client wishes to process if the field 1155 semantics are such that the dropped value(s) can be safely ignored 1156 without changing the response semantics. 1158 3.2.6. Field value components 1160 Many HTTP header field values consist of words (token or quoted- 1161 string) separated by whitespace or special characters. These special 1162 characters MUST be in a quoted string to be used within a parameter 1163 value (as defined in Section 4). 1165 word = token / quoted-string 1167 token = 1*tchar 1169 tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" 1170 / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" 1171 / DIGIT / ALPHA 1172 ; any VCHAR, except special 1174 special = "(" / ")" / "<" / ">" / "@" / "," 1175 / ";" / ":" / "\" / DQUOTE / "/" / "[" 1176 / "]" / "?" / "=" / "{" / "}" 1178 A string of text is parsed as a single word if it is quoted using 1179 double-quote marks. 1181 quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE 1182 qdtext = HTAB / SP /%x21 / %x23-5B / %x5D-7E / obs-text 1183 obs-text = %x80-FF 1185 The backslash octet ("\") can be used as a single-octet quoting 1186 mechanism within quoted-string constructs: 1188 quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) 1190 Recipients that process the value of a quoted-string MUST handle a 1191 quoted-pair as if it were replaced by the octet following the 1192 backslash. 1194 Senders SHOULD NOT generate a quoted-pair in a quoted-string except 1195 where necessary to quote DQUOTE and backslash octets occurring within 1196 that string. 1198 Comments can be included in some HTTP header fields by surrounding 1199 the comment text with parentheses. Comments are only allowed in 1200 fields containing "comment" as part of their field value definition. 1202 comment = "(" *( ctext / quoted-cpair / comment ) ")" 1203 ctext = HTAB / SP / %x21-27 / %x2A-5B / %x5D-7E / obs-text 1205 The backslash octet ("\") can be used as a single-octet quoting 1206 mechanism within comment constructs: 1208 quoted-cpair = "\" ( HTAB / SP / VCHAR / obs-text ) 1210 Senders SHOULD NOT escape octets in comments that do not require 1211 escaping (i.e., other than the backslash octet "\" and the 1212 parentheses "(" and ")"). 1214 3.3. Message Body 1216 The message body (if any) of an HTTP message is used to carry the 1217 payload body of that request or response. The message body is 1218 identical to the payload body unless a transfer coding has been 1219 applied, as described in Section 3.3.1. 1221 message-body = *OCTET 1223 The rules for when a message body is allowed in a message differ for 1224 requests and responses. 1226 The presence of a message body in a request is signaled by a Content- 1227 Length or Transfer-Encoding header field. Request message framing is 1228 independent of method semantics, even if the method does not define 1229 any use for a message body. 1231 The presence of a message body in a response depends on both the 1232 request method to which it is responding and the response status code 1233 (Section 3.1.2). Responses to the HEAD request method never include 1234 a message body because the associated response header fields (e.g., 1235 Transfer-Encoding, Content-Length, etc.), if present, indicate only 1236 what their values would have been if the request method had been GET 1237 (Section 4.3.2 of [Part2]). 2xx (Successful) responses to CONNECT 1238 switch to tunnel mode instead of having a message body (Section 4.3.6 1239 of [Part2]). All 1xx (Informational), 204 (No Content), and 304 (Not 1240 Modified) responses do not include a message body. All other 1241 responses do include a message body, although the body might be of 1242 zero length. 1244 3.3.1. Transfer-Encoding 1246 The Transfer-Encoding header field lists the transfer coding names 1247 corresponding to the sequence of transfer codings that have been (or 1248 will be) applied to the payload body in order to form the message 1249 body. Transfer codings are defined in Section 4. 1251 Transfer-Encoding = 1#transfer-coding 1253 Transfer-Encoding is analogous to the Content-Transfer-Encoding field 1254 of MIME, which was designed to enable safe transport of binary data 1255 over a 7-bit transport service ([RFC2045], Section 6). However, safe 1256 transport has a different focus for an 8bit-clean transfer protocol. 1257 In HTTP's case, Transfer-Encoding is primarily intended to accurately 1258 delimit a dynamically generated payload and to distinguish payload 1259 encodings that are only applied for transport efficiency or security 1260 from those that are characteristics of the selected resource. 1262 All HTTP/1.1 recipients MUST implement the chunked transfer coding 1263 (Section 4.1) because it plays a crucial role in framing messages 1264 when the payload body size is not known in advance. If chunked is 1265 applied to a payload body, the sender MUST NOT apply chunked more 1266 than once (i.e., chunking an already chunked message is not allowed). 1267 If any transfer coding is applied to a request payload body, the 1268 sender MUST apply chunked as the final transfer coding to ensure that 1269 the message is properly framed. If any transfer coding is applied to 1270 a response payload body, the sender MUST either apply chunked as the 1271 final transfer coding or terminate the message by closing the 1272 connection. 1274 For example, 1276 Transfer-Encoding: gzip, chunked 1278 indicates that the payload body has been compressed using the gzip 1279 coding and then chunked using the chunked coding while forming the 1280 message body. 1282 Unlike Content-Encoding (Section 3.1.2.1 of [Part2]), Transfer- 1283 Encoding is a property of the message, not of the representation, and 1284 any recipient along the request/response chain MAY decode the 1285 received transfer coding(s) or apply additional transfer coding(s) to 1286 the message body, assuming that corresponding changes are made to the 1287 Transfer-Encoding field-value. Additional information about the 1288 encoding parameters MAY be provided by other header fields not 1289 defined by this specification. 1291 Transfer-Encoding MAY be sent in a response to a HEAD request or in a 1292 304 (Not Modified) response (Section 4.1 of [Part4]) to a GET 1293 request, neither of which includes a message body, to indicate that 1294 the origin server would have applied a transfer coding to the message 1295 body if the request had been an unconditional GET. This indication 1296 is not required, however, because any recipient on the response chain 1297 (including the origin server) can remove transfer codings when they 1298 are not needed. 1300 Transfer-Encoding was added in HTTP/1.1. It is generally assumed 1301 that implementations advertising only HTTP/1.0 support will not 1302 understand how to process a transfer-encoded payload. A client MUST 1303 NOT send a request containing Transfer-Encoding unless it knows the 1304 server will handle HTTP/1.1 (or later) requests; such knowledge might 1305 be in the form of specific user configuration or by remembering the 1306 version of a prior received response. A server MUST NOT send a 1307 response containing Transfer-Encoding unless the corresponding 1308 request indicates HTTP/1.1 (or later). 1310 A server that receives a request message with a transfer coding it 1311 does not understand SHOULD respond with 501 (Not Implemented). 1313 3.3.2. Content-Length 1315 When a message does not have a Transfer-Encoding header field, a 1316 Content-Length header field can provide the anticipated size, as a 1317 decimal number of octets, for a potential payload body. For messages 1318 that do include a payload body, the Content-Length field-value 1319 provides the framing information necessary for determining where the 1320 body (and message) ends. For messages that do not include a payload 1321 body, the Content-Length indicates the size of the selected 1322 representation (Section 3 of [Part2]). 1324 Content-Length = 1*DIGIT 1326 An example is 1328 Content-Length: 3495 1330 A sender MUST NOT send a Content-Length header field in any message 1331 that contains a Transfer-Encoding header field. 1333 A user agent SHOULD send a Content-Length in a request message when 1334 no Transfer-Encoding is sent and the request method defines a meaning 1335 for an enclosed payload body. For example, a Content-Length header 1336 field is normally sent in a POST request even when the value is 0 1337 (indicating an empty payload body). A user agent SHOULD NOT send a 1338 Content-Length header field when the request message does not contain 1339 a payload body and the method semantics do not anticipate such a 1340 body. 1342 A server MAY send a Content-Length header field in a response to a 1343 HEAD request (Section 4.3.2 of [Part2]); a server MUST NOT send 1344 Content-Length in such a response unless its field-value equals the 1345 decimal number of octets that would have been sent in the payload 1346 body of a response if the same request had used the GET method. 1348 A server MAY send a Content-Length header field in a 304 (Not 1349 Modified) response to a conditional GET request (Section 4.1 of 1350 [Part4]); a server MUST NOT send Content-Length in such a response 1351 unless its field-value equals the decimal number of octets that would 1352 have been sent in the payload body of a 200 (OK) response to the same 1353 request. 1355 A server MUST NOT send a Content-Length header field in any response 1356 with a status code of 1xx (Informational) or 204 (No Content). A 1357 server SHOULD NOT send a Content-Length header field in any 2xx 1358 (Successful) response to a CONNECT request (Section 4.3.6 of 1359 [Part2]). 1361 Aside from the cases defined above, in the absence of Transfer- 1362 Encoding, an origin server SHOULD send a Content-Length header field 1363 when the payload body size is known prior to sending the complete 1364 header block. This will allow downstream recipients to measure 1365 transfer progress, know when a received message is complete, and 1366 potentially reuse the connection for additional requests. 1368 Any Content-Length field value greater than or equal to zero is 1369 valid. Since there is no predefined limit to the length of a 1370 payload, recipients SHOULD anticipate potentially large decimal 1371 numerals and prevent parsing errors due to integer conversion 1372 overflows (Section 8.3). 1374 If a message is received that has multiple Content-Length header 1375 fields with field-values consisting of the same decimal value, or a 1376 single Content-Length header field with a field value containing a 1377 list of identical decimal values (e.g., "Content-Length: 42, 42"), 1378 indicating that duplicate Content-Length header fields have been 1379 generated or combined by an upstream message processor, then the 1380 recipient MUST either reject the message as invalid or replace the 1381 duplicated field-values with a single valid Content-Length field 1382 containing that decimal value prior to determining the message body 1383 length. 1385 Note: HTTP's use of Content-Length for message framing differs 1386 significantly from the same field's use in MIME, where it is an 1387 optional field used only within the "message/external-body" media- 1388 type. 1390 3.3.3. Message Body Length 1392 The length of a message body is determined by one of the following 1393 (in order of precedence): 1395 1. Any response to a HEAD request and any response with a 1xx 1396 (Informational), 204 (No Content), or 304 (Not Modified) status 1397 code is always terminated by the first empty line after the 1398 header fields, regardless of the header fields present in the 1399 message, and thus cannot contain a message body. 1401 2. Any 2xx (Successful) response to a CONNECT request implies that 1402 the connection will become a tunnel immediately after the empty 1403 line that concludes the header fields. A client MUST ignore any 1404 Content-Length or Transfer-Encoding header fields received in 1405 such a message. 1407 3. If a Transfer-Encoding header field is present and the chunked 1408 transfer coding (Section 4.1) is the final encoding, the message 1409 body length is determined by reading and decoding the chunked 1410 data until the transfer coding indicates the data is complete. 1412 If a Transfer-Encoding header field is present in a response and 1413 the chunked transfer coding is not the final encoding, the 1414 message body length is determined by reading the connection until 1415 it is closed by the server. If a Transfer-Encoding header field 1416 is present in a request and the chunked transfer coding is not 1417 the final encoding, the message body length cannot be determined 1418 reliably; the server MUST respond with the 400 (Bad Request) 1419 status code and then close the connection. 1421 If a message is received with both a Transfer-Encoding and a 1422 Content-Length header field, the Transfer-Encoding overrides the 1423 Content-Length. Such a message might indicate an attempt to 1424 perform request or response smuggling (bypass of security-related 1425 checks on message routing or content) and thus ought to be 1426 handled as an error. A sender MUST remove the received Content- 1427 Length field prior to forwarding such a message downstream. 1429 4. If a message is received without Transfer-Encoding and with 1430 either multiple Content-Length header fields having differing 1431 field-values or a single Content-Length header field having an 1432 invalid value, then the message framing is invalid and MUST be 1433 treated as an error to prevent request or response smuggling. If 1434 this is a request message, the server MUST respond with a 400 1435 (Bad Request) status code and then close the connection. If this 1436 is a response message received by a proxy, the proxy MUST discard 1437 the received response, send a 502 (Bad Gateway) status code as 1438 its downstream response, and then close the connection. If this 1439 is a response message received by a user agent, it MUST be 1440 treated as an error by discarding the message and closing the 1441 connection. 1443 5. If a valid Content-Length header field is present without 1444 Transfer-Encoding, its decimal value defines the expected message 1445 body length in octets. If the sender closes the connection or 1446 the recipient times out before the indicated number of octets are 1447 received, the recipient MUST consider the message to be 1448 incomplete and close the connection. 1450 6. If this is a request message and none of the above are true, then 1451 the message body length is zero (no message body is present). 1453 7. Otherwise, this is a response message without a declared message 1454 body length, so the message body length is determined by the 1455 number of octets received prior to the server closing the 1456 connection. 1458 Since there is no way to distinguish a successfully completed, close- 1459 delimited message from a partially-received message interrupted by 1460 network failure, a server SHOULD use encoding or length-delimited 1461 messages whenever possible. The close-delimiting feature exists 1462 primarily for backwards compatibility with HTTP/1.0. 1464 A server MAY reject a request that contains a message body but not a 1465 Content-Length by responding with 411 (Length Required). 1467 Unless a transfer coding other than chunked has been applied, a 1468 client that sends a request containing a message body SHOULD use a 1469 valid Content-Length header field if the message body length is known 1470 in advance, rather than the chunked transfer coding, since some 1471 existing services respond to chunked with a 411 (Length Required) 1472 status code even though they understand the chunked transfer coding. 1473 This is typically because such services are implemented via a gateway 1474 that requires a content-length in advance of being called and the 1475 server is unable or unwilling to buffer the entire request before 1476 processing. 1478 A user agent that sends a request containing a message body MUST send 1479 a valid Content-Length header field if it does not know the server 1480 will handle HTTP/1.1 (or later) requests; such knowledge can be in 1481 the form of specific user configuration or by remembering the version 1482 of a prior received response. 1484 If the final response to the last request on a connection has been 1485 completely received and there remains additional data to read, a user 1486 agent MAY discard the remaining data or attempt to determine if that 1487 data belongs as part of the prior response body, which might be the 1488 case if the prior message's Content-Length value is incorrect. A 1489 client MUST NOT process, cache, or forward such extra data as a 1490 separate response, since such behavior would be vulnerable to cache 1491 poisoning. 1493 3.4. Handling Incomplete Messages 1495 A server that receives an incomplete request message, usually due to 1496 a canceled request or a triggered time-out exception, MAY send an 1497 error response prior to closing the connection. 1499 A client that receives an incomplete response message, which can 1500 occur when a connection is closed prematurely or when decoding a 1501 supposedly chunked transfer coding fails, MUST record the message as 1502 incomplete. Cache requirements for incomplete responses are defined 1503 in Section 3 of [Part6]. 1505 If a response terminates in the middle of the header block (before 1506 the empty line is received) and the status code might rely on header 1507 fields to convey the full meaning of the response, then the client 1508 cannot assume that meaning has been conveyed; the client might need 1509 to repeat the request in order to determine what action to take next. 1511 A message body that uses the chunked transfer coding is incomplete if 1512 the zero-sized chunk that terminates the encoding has not been 1513 received. A message that uses a valid Content-Length is incomplete 1514 if the size of the message body received (in octets) is less than the 1515 value given by Content-Length. A response that has neither chunked 1516 transfer coding nor Content-Length is terminated by closure of the 1517 connection, and thus is considered complete regardless of the number 1518 of message body octets received, provided that the header block was 1519 received intact. 1521 3.5. Message Parsing Robustness 1523 Older HTTP/1.0 user agent implementations might send an extra CRLF 1524 after a POST request as a lame workaround for some early server 1525 applications that failed to read message body content that was not 1526 terminated by a line-ending. An HTTP/1.1 user agent MUST NOT preface 1527 or follow a request with an extra CRLF. If terminating the request 1528 message body with a line-ending is desired, then the user agent MUST 1529 count the terminating CRLF octets as part of the message body length. 1531 In the interest of robustness, servers SHOULD ignore at least one 1532 empty line received where a request-line is expected. In other 1533 words, if a server is reading the protocol stream at the beginning of 1534 a message and receives a CRLF first, the server SHOULD ignore the 1535 CRLF. 1537 Although the line terminator for the start-line and header fields is 1538 the sequence CRLF, recipients MAY recognize a single LF as a line 1539 terminator and ignore any preceding CR. 1541 Although the request-line and status-line grammar rules require that 1542 each of the component elements be separated by a single SP octet, 1543 recipients MAY instead parse on whitespace-delimited word boundaries 1544 and, aside from the CRLF terminator, treat any form of whitespace as 1545 the SP separator while ignoring preceding or trailing whitespace; 1546 such whitespace includes one or more of the following octets: SP, 1547 HTAB, VT (%x0B), FF (%x0C), or bare CR. 1549 When a server listening only for HTTP request messages, or processing 1550 what appears from the start-line to be an HTTP request message, 1551 receives a sequence of octets that does not match the HTTP-message 1552 grammar aside from the robustness exceptions listed above, the server 1553 SHOULD respond with a 400 (Bad Request) response. 1555 4. Transfer Codings 1557 Transfer coding names are used to indicate an encoding transformation 1558 that has been, can be, or might need to be applied to a payload body 1559 in order to ensure "safe transport" through the network. This 1560 differs from a content coding in that the transfer coding is a 1561 property of the message rather than a property of the representation 1562 that is being transferred. 1564 transfer-coding = "chunked" ; Section 4.1 1565 / "compress" ; Section 4.2.1 1566 / "deflate" ; Section 4.2.2 1567 / "gzip" ; Section 4.2.3 1568 / transfer-extension 1569 transfer-extension = token *( OWS ";" OWS transfer-parameter ) 1571 Parameters are in the form of attribute/value pairs. 1573 transfer-parameter = attribute BWS "=" BWS value 1574 attribute = token 1575 value = word 1577 All transfer-coding names are case-insensitive and ought to be 1578 registered within the HTTP Transfer Coding registry, as defined in 1579 Section 7.4. They are used in the TE (Section 4.3) and Transfer- 1580 Encoding (Section 3.3.1) header fields. 1582 4.1. Chunked Transfer Coding 1584 The chunked transfer coding modifies the body of a message in order 1585 to transfer it as a series of chunks, each with its own size 1586 indicator, followed by an OPTIONAL trailer containing header fields. 1587 This allows dynamically generated content to be transferred along 1588 with the information necessary for the recipient to verify that it 1589 has received the full message. 1591 chunked-body = *chunk 1592 last-chunk 1593 trailer-part 1594 CRLF 1596 chunk = chunk-size [ chunk-ext ] CRLF 1597 chunk-data CRLF 1598 chunk-size = 1*HEXDIG 1599 last-chunk = 1*("0") [ chunk-ext ] CRLF 1601 chunk-ext = *( ";" chunk-ext-name [ "=" chunk-ext-val ] ) 1602 chunk-ext-name = token 1603 chunk-ext-val = token / quoted-str-nf 1604 chunk-data = 1*OCTET ; a sequence of chunk-size octets 1605 trailer-part = *( header-field CRLF ) 1607 quoted-str-nf = DQUOTE *( qdtext-nf / quoted-pair ) DQUOTE 1608 ; like quoted-string, but disallowing line folding 1609 qdtext-nf = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text 1611 Chunk extensions within the chunked transfer coding are deprecated. 1612 Senders SHOULD NOT send chunk-ext. Definition of new chunk 1613 extensions is discouraged. 1615 The chunk-size field is a string of hex digits indicating the size of 1616 the chunk-data in octets. The chunked transfer coding is complete 1617 when a chunk with a chunk-size of zero is received, possibly followed 1618 by a trailer, and finally terminated by an empty line. 1620 4.1.1. Trailer 1622 A trailer allows the sender to include additional fields at the end 1623 of a chunked message in order to supply metadata that might be 1624 dynamically generated while the message body is sent, such as a 1625 message integrity check, digital signature, or post-processing 1626 status. The trailer MUST NOT contain fields that need to be known 1627 before a recipient processes the body, such as Transfer-Encoding, 1628 Content-Length, and Trailer. 1630 When a message includes a message body encoded with the chunked 1631 transfer coding and the sender desires to send metadata in the form 1632 of trailer fields at the end of the message, the sender SHOULD send a 1633 Trailer header field before the message body to indicate which fields 1634 will be present in the trailers. This allows the recipient to 1635 prepare for receipt of that metadata before it starts processing the 1636 body, which is useful if the message is being streamed and the 1637 recipient wishes to confirm an integrity check on the fly. 1639 Trailer = 1#field-name 1641 If no Trailer header field is present, the sender of a chunked 1642 message body SHOULD send an empty trailer. 1644 A server MUST send an empty trailer with the chunked transfer coding 1645 unless at least one of the following is true: 1647 1. the request included a TE header field that indicates "trailers" 1648 is acceptable in the transfer coding of the response, as 1649 described in Section 4.3; or, 1651 2. the trailer fields consist entirely of optional metadata and the 1652 recipient could use the message (in a manner acceptable to the 1653 server where the field originated) without receiving that 1654 metadata. In other words, the server that generated the header 1655 field is willing to accept the possibility that the trailer 1656 fields might be silently discarded along the path to the client. 1658 The above requirement prevents the need for an infinite buffer when a 1659 message is being received by an HTTP/1.1 (or later) proxy and 1660 forwarded to an HTTP/1.0 recipient. 1662 4.1.2. Decoding chunked 1664 A process for decoding the chunked transfer coding can be represented 1665 in pseudo-code as: 1667 length := 0 1668 read chunk-size, chunk-ext (if any) and CRLF 1669 while (chunk-size > 0) { 1670 read chunk-data and CRLF 1671 append chunk-data to decoded-body 1672 length := length + chunk-size 1673 read chunk-size and CRLF 1674 } 1675 read header-field 1676 while (header-field not empty) { 1677 append header-field to existing header fields 1678 read header-field 1679 } 1680 Content-Length := length 1681 Remove "chunked" from Transfer-Encoding 1682 Remove Trailer from existing header fields 1684 All recipients MUST be able to receive and decode the chunked 1685 transfer coding and MUST ignore chunk-ext extensions they do not 1686 understand. 1688 4.2. Compression Codings 1690 The codings defined below can be used to compress the payload of a 1691 message. 1693 4.2.1. Compress Coding 1695 The "compress" format is produced by the common UNIX file compression 1696 program "compress". This format is an adaptive Lempel-Ziv-Welch 1697 coding (LZW). Recipients SHOULD consider "x-compress" to be 1698 equivalent to "compress". 1700 4.2.2. Deflate Coding 1702 The "deflate" format is defined as the "deflate" compression 1703 mechanism (described in [RFC1951]) used inside the "zlib" data format 1704 ([RFC1950]). 1706 Note: Some incorrect implementations send the "deflate" compressed 1707 data without the zlib wrapper. 1709 4.2.3. Gzip Coding 1711 The "gzip" format is produced by the file compression program "gzip" 1712 (GNU zip), as described in [RFC1952]. This format is a Lempel-Ziv 1713 coding (LZ77) with a 32 bit CRC. Recipients SHOULD consider "x-gzip" 1714 to be equivalent to "gzip". 1716 4.3. TE 1718 The "TE" header field in a request indicates what transfer codings, 1719 besides chunked, the client is willing to accept in response, and 1720 whether or not the client is willing to accept trailer fields in a 1721 chunked transfer coding. 1723 The TE field-value consists of a comma-separated list of transfer 1724 coding names, each allowing for optional parameters (as described in 1725 Section 4), and/or the keyword "trailers". Clients MUST NOT send the 1726 chunked transfer coding name in TE; chunked is always acceptable for 1727 HTTP/1.1 recipients. 1729 TE = #t-codings 1730 t-codings = "trailers" / ( transfer-coding [ t-ranking ] ) 1731 t-ranking = OWS ";" OWS "q=" rank 1732 rank = ( "0" [ "." 0*3DIGIT ] ) 1733 / ( "1" [ "." 0*3("0") ] ) 1735 Three examples of TE use are below. 1737 TE: deflate 1738 TE: 1739 TE: trailers, deflate;q=0.5 1741 The presence of the keyword "trailers" indicates that the client is 1742 willing to accept trailer fields in a chunked transfer coding, as 1743 defined in Section 4.1, on behalf of itself and any downstream 1744 clients. For chained requests, this implies that either: (a) all 1745 downstream clients are willing to accept trailer fields in the 1746 forwarded response; or, (b) the client will attempt to buffer the 1747 response on behalf of downstream recipients. Note that HTTP/1.1 does 1748 not define any means to limit the size of a chunked response such 1749 that a client can be assured of buffering the entire response. 1751 When multiple transfer codings are acceptable, the client MAY rank 1752 the codings by preference using a case-insensitive "q" parameter 1753 (similar to the qvalues used in content negotiation fields, Section 1754 5.3.1 of [Part2]). The rank value is a real number in the range 0 1755 through 1, where 0.001 is the least preferred and 1 is the most 1756 preferred; a value of 0 means "not acceptable". 1758 If the TE field-value is empty or if no TE field is present, the only 1759 acceptable transfer coding is chunked. A message with no transfer 1760 coding is always acceptable. 1762 Since the TE header field only applies to the immediate connection, a 1763 sender of TE MUST also send a "TE" connection option within the 1764 Connection header field (Section 6.1) in order to prevent the TE 1765 field from being forwarded by intermediaries that do not support its 1766 semantics. 1768 5. Message Routing 1770 HTTP request message routing is determined by each client based on 1771 the target resource, the client's proxy configuration, and 1772 establishment or reuse of an inbound connection. The corresponding 1773 response routing follows the same connection chain back to the 1774 client. 1776 5.1. Identifying a Target Resource 1778 HTTP is used in a wide variety of applications, ranging from general- 1779 purpose computers to home appliances. In some cases, communication 1780 options are hard-coded in a client's configuration. However, most 1781 HTTP clients rely on the same resource identification mechanism and 1782 configuration techniques as general-purpose Web browsers. 1784 HTTP communication is initiated by a user agent for some purpose. 1786 The purpose is a combination of request semantics, which are defined 1787 in [Part2], and a target resource upon which to apply those 1788 semantics. A URI reference (Section 2.7) is typically used as an 1789 identifier for the "target resource", which a user agent would 1790 resolve to its absolute form in order to obtain the "target URI". 1791 The target URI excludes the reference's fragment identifier 1792 component, if any, since fragment identifiers are reserved for 1793 client-side processing ([RFC3986], Section 3.5). 1795 5.2. Connecting Inbound 1797 Once the target URI is determined, a client needs to decide whether a 1798 network request is necessary to accomplish the desired semantics and, 1799 if so, where that request is to be directed. 1801 If the client has a response cache and the request semantics can be 1802 satisfied by a cache ([Part6]), then the request is usually directed 1803 to the cache first. 1805 If the request is not satisfied by a cache, then a typical client 1806 will check its configuration to determine whether a proxy is to be 1807 used to satisfy the request. Proxy configuration is implementation- 1808 dependent, but is often based on URI prefix matching, selective 1809 authority matching, or both, and the proxy itself is usually 1810 identified by an "http" or "https" URI. If a proxy is applicable, 1811 the client connects inbound by establishing (or reusing) a connection 1812 to that proxy. 1814 If no proxy is applicable, a typical client will invoke a handler 1815 routine, usually specific to the target URI's scheme, to connect 1816 directly to an authority for the target resource. How that is 1817 accomplished is dependent on the target URI scheme and defined by its 1818 associated specification, similar to how this specification defines 1819 origin server access for resolution of the "http" (Section 2.7.1) and 1820 "https" (Section 2.7.2) schemes. 1822 HTTP requirements regarding connection management are defined in 1823 Section 6. 1825 5.3. Request Target 1827 Once an inbound connection is obtained, the client sends an HTTP 1828 request message (Section 3) with a request-target derived from the 1829 target URI. There are four distinct formats for the request-target, 1830 depending on both the method being requested and whether the request 1831 is to a proxy. 1833 request-target = origin-form 1834 / absolute-form 1835 / authority-form 1836 / asterisk-form 1838 origin-form = absolute-path [ "?" query ] 1839 absolute-form = absolute-URI 1840 authority-form = authority 1841 asterisk-form = "*" 1843 origin-form 1845 The most common form of request-target is the origin-form. When 1846 making a request directly to an origin server, other than a CONNECT 1847 or server-wide OPTIONS request (as detailed below), a client MUST 1848 send only the absolute path and query components of the target URI as 1849 the request-target. If the target URI's path component is empty, 1850 then the client MUST send "/" as the path within the origin-form of 1851 request-target. A Host header field is also sent, as defined in 1852 Section 5.4, containing the target URI's authority component 1853 (excluding any userinfo). 1855 For example, a client wishing to retrieve a representation of the 1856 resource identified as 1858 http://www.example.org/where?q=now 1860 directly from the origin server would open (or reuse) a TCP 1861 connection to port 80 of the host "www.example.org" and send the 1862 lines: 1864 GET /where?q=now HTTP/1.1 1865 Host: www.example.org 1867 followed by the remainder of the request message. 1869 absolute-form 1871 When making a request to a proxy, other than a CONNECT or server-wide 1872 OPTIONS request (as detailed below), a client MUST send the target 1873 URI in absolute-form as the request-target. The proxy is requested 1874 to either service that request from a valid cache, if possible, or 1875 make the same request on the client's behalf to either the next 1876 inbound proxy server or directly to the origin server indicated by 1877 the request-target. Requirements on such "forwarding" of messages 1878 are defined in Section 5.7. 1880 An example absolute-form of request-line would be: 1882 GET http://www.example.org/pub/WWW/TheProject.html HTTP/1.1 1884 To allow for transition to the absolute-form for all requests in some 1885 future version of HTTP, HTTP/1.1 servers MUST accept the absolute- 1886 form in requests, even though HTTP/1.1 clients will only send them in 1887 requests to proxies. 1889 authority-form 1891 The authority-form of request-target is only used for CONNECT 1892 requests (Section 4.3.6 of [Part2]). When making a CONNECT request 1893 to establish a tunnel through one or more proxies, a client MUST send 1894 only the target URI's authority component (excluding any userinfo) as 1895 the request-target. For example, 1897 CONNECT www.example.com:80 HTTP/1.1 1899 asterisk-form 1901 The asterisk-form of request-target is only used for a server-wide 1902 OPTIONS request (Section 4.3.7 of [Part2]). When a client wishes to 1903 request OPTIONS for the server as a whole, as opposed to a specific 1904 named resource of that server, the client MUST send only "*" (%x2A) 1905 as the request-target. For example, 1907 OPTIONS * HTTP/1.1 1909 If a proxy receives an OPTIONS request with an absolute-form of 1910 request-target in which the URI has an empty path and no query 1911 component, then the last proxy on the request chain MUST send a 1912 request-target of "*" when it forwards the request to the indicated 1913 origin server. 1915 For example, the request 1917 OPTIONS http://www.example.org:8001 HTTP/1.1 1919 would be forwarded by the final proxy as 1921 OPTIONS * HTTP/1.1 1922 Host: www.example.org:8001 1924 after connecting to port 8001 of host "www.example.org". 1926 5.4. Host 1928 The "Host" header field in a request provides the host and port 1929 information from the target URI, enabling the origin server to 1930 distinguish among resources while servicing requests for multiple 1931 host names on a single IP address. Since the Host field-value is 1932 critical information for handling a request, it SHOULD be sent as the 1933 first header field following the request-line. 1935 Host = uri-host [ ":" port ] ; Section 2.7.1 1937 A client MUST send a Host header field in all HTTP/1.1 request 1938 messages. If the target URI includes an authority component, then 1939 the Host field-value MUST be identical to that authority component 1940 after excluding any userinfo (Section 2.7.1). If the authority 1941 component is missing or undefined for the target URI, then the Host 1942 header field MUST be sent with an empty field-value. 1944 For example, a GET request to the origin server for 1945 would begin with: 1947 GET /pub/WWW/ HTTP/1.1 1948 Host: www.example.org 1950 The Host header field MUST be sent in an HTTP/1.1 request even if the 1951 request-target is in the absolute-form, since this allows the Host 1952 information to be forwarded through ancient HTTP/1.0 proxies that 1953 might not have implemented Host. 1955 When a proxy receives a request with an absolute-form of request- 1956 target, the proxy MUST ignore the received Host header field (if any) 1957 and instead replace it with the host information of the request- 1958 target. If the proxy forwards the request, it MUST generate a new 1959 Host field-value based on the received request-target rather than 1960 forward the received Host field-value. 1962 Since the Host header field acts as an application-level routing 1963 mechanism, it is a frequent target for malware seeking to poison a 1964 shared cache or redirect a request to an unintended server. An 1965 interception proxy is particularly vulnerable if it relies on the 1966 Host field-value for redirecting requests to internal servers, or for 1967 use as a cache key in a shared cache, without first verifying that 1968 the intercepted connection is targeting a valid IP address for that 1969 host. 1971 A server MUST respond with a 400 (Bad Request) status code to any 1972 HTTP/1.1 request message that lacks a Host header field and to any 1973 request message that contains more than one Host header field or a 1974 Host header field with an invalid field-value. 1976 5.5. Effective Request URI 1978 A server that receives an HTTP request message MUST reconstruct the 1979 user agent's original target URI, based on the pieces of information 1980 learned from the request-target, Host header field, and connection 1981 context, in order to identify the intended target resource and 1982 properly service the request. The URI derived from this 1983 reconstruction process is referred to as the "effective request URI". 1985 For a user agent, the effective request URI is the target URI. 1987 If the request-target is in absolute-form, then the effective request 1988 URI is the same as the request-target. Otherwise, the effective 1989 request URI is constructed as follows. 1991 If the request is received over a TLS-secured TCP connection, then 1992 the effective request URI's scheme is "https"; otherwise, the scheme 1993 is "http". 1995 If the request-target is in authority-form, then the effective 1996 request URI's authority component is the same as the request-target. 1997 Otherwise, if a Host header field is supplied with a non-empty field- 1998 value, then the authority component is the same as the Host field- 1999 value. Otherwise, the authority component is the concatenation of 2000 the default host name configured for the server, a colon (":"), and 2001 the connection's incoming TCP port number in decimal form. 2003 If the request-target is in authority-form or asterisk-form, then the 2004 effective request URI's combined path and query component is empty. 2005 Otherwise, the combined path and query component is the same as the 2006 request-target. 2008 The components of the effective request URI, once determined as 2009 above, can be combined into absolute-URI form by concatenating the 2010 scheme, "://", authority, and combined path and query component. 2012 Example 1: the following message received over an insecure TCP 2013 connection 2015 GET /pub/WWW/TheProject.html HTTP/1.1 2016 Host: www.example.org:8080 2018 has an effective request URI of 2020 http://www.example.org:8080/pub/WWW/TheProject.html 2022 Example 2: the following message received over a TLS-secured TCP 2023 connection 2025 OPTIONS * HTTP/1.1 2026 Host: www.example.org 2028 has an effective request URI of 2030 https://www.example.org 2032 An origin server that does not allow resources to differ by requested 2033 host MAY ignore the Host field-value and instead replace it with a 2034 configured server name when constructing the effective request URI. 2036 Recipients of an HTTP/1.0 request that lacks a Host header field MAY 2037 attempt to use heuristics (e.g., examination of the URI path for 2038 something unique to a particular host) in order to guess the 2039 effective request URI's authority component. 2041 5.6. Associating a Response to a Request 2043 HTTP does not include a request identifier for associating a given 2044 request message with its corresponding one or more response messages. 2045 Hence, it relies on the order of response arrival to correspond 2046 exactly to the order in which requests are made on the same 2047 connection. More than one response message per request only occurs 2048 when one or more informational responses (1xx, see Section 6.2 of 2049 [Part2]) precede a final response to the same request. 2051 A client that has more than one outstanding request on a connection 2052 MUST maintain a list of outstanding requests in the order sent and 2053 MUST associate each received response message on that connection to 2054 the highest ordered request that has not yet received a final (non- 2055 1xx) response. 2057 5.7. Message Forwarding 2059 As described in Section 2.3, intermediaries can serve a variety of 2060 roles in the processing of HTTP requests and responses. Some 2061 intermediaries are used to improve performance or availability. 2062 Others are used for access control or to filter content. Since an 2063 HTTP stream has characteristics similar to a pipe-and-filter 2064 architecture, there are no inherent limits to the extent an 2065 intermediary can enhance (or interfere) with either direction of the 2066 stream. 2068 Intermediaries that forward a message MUST implement the Connection 2069 header field, as specified in Section 6.1, to exclude fields that are 2070 only intended for the incoming connection. 2072 In order to avoid request loops, a proxy that forwards requests to 2073 other proxies MUST be able to recognize and exclude all of its own 2074 server names, including any aliases, local variations, or literal IP 2075 addresses. 2077 5.7.1. Via 2079 The "Via" header field MUST be sent by a proxy or gateway in 2080 forwarded messages to indicate the intermediate protocols and 2081 recipients between the user agent and the server on requests, and 2082 between the origin server and the client on responses. It is 2083 analogous to the "Received" field used by email systems (Section 2084 3.6.7 of [RFC5322]). Via is used in HTTP for tracking message 2085 forwards, avoiding request loops, and identifying the protocol 2086 capabilities of all senders along the request/response chain. 2088 Via = 1#( received-protocol RWS received-by 2089 [ RWS comment ] ) 2090 received-protocol = [ protocol-name "/" ] protocol-version 2091 ; see Section 6.7 2092 received-by = ( uri-host [ ":" port ] ) / pseudonym 2093 pseudonym = token 2095 The received-protocol indicates the protocol version of the message 2096 received by the server or client along each segment of the request/ 2097 response chain. The received-protocol version is appended to the Via 2098 field value when the message is forwarded so that information about 2099 the protocol capabilities of upstream applications remains visible to 2100 all recipients. 2102 The protocol-name is excluded if and only if it would be "HTTP". The 2103 received-by field is normally the host and optional port number of a 2104 recipient server or client that subsequently forwarded the message. 2105 However, if the real host is considered to be sensitive information, 2106 it MAY be replaced by a pseudonym. If the port is not given, it MAY 2107 be assumed to be the default port of the received-protocol. 2109 Multiple Via field values represent each proxy or gateway that has 2110 forwarded the message. Each recipient MUST append its information 2111 such that the end result is ordered according to the sequence of 2112 forwarding applications. 2114 Comments MAY be used in the Via header field to identify the software 2115 of each recipient, analogous to the User-Agent and Server header 2116 fields. However, all comments in the Via field are optional and MAY 2117 be removed by any recipient prior to forwarding the message. 2119 For example, a request message could be sent from an HTTP/1.0 user 2120 agent to an internal proxy code-named "fred", which uses HTTP/1.1 to 2121 forward the request to a public proxy at p.example.net, which 2122 completes the request by forwarding it to the origin server at 2123 www.example.com. The request received by www.example.com would then 2124 have the following Via header field: 2126 Via: 1.0 fred, 1.1 p.example.net (Apache/1.1) 2128 A proxy or gateway used as a portal through a network firewall SHOULD 2129 NOT forward the names and ports of hosts within the firewall region 2130 unless it is explicitly enabled to do so. If not enabled, the 2131 received-by host of any host behind the firewall SHOULD be replaced 2132 by an appropriate pseudonym for that host. 2134 A proxy or gateway MAY combine an ordered subsequence of Via header 2135 field entries into a single such entry if the entries have identical 2136 received-protocol values. For example, 2138 Via: 1.0 ricky, 1.1 ethel, 1.1 fred, 1.0 lucy 2140 could be collapsed to 2142 Via: 1.0 ricky, 1.1 mertz, 1.0 lucy 2144 Senders SHOULD NOT combine multiple entries unless they are all under 2145 the same organizational control and the hosts have already been 2146 replaced by pseudonyms. Senders MUST NOT combine entries that have 2147 different received-protocol values. 2149 5.7.2. Transformations 2151 Some intermediaries include features for transforming messages and 2152 their payloads. A transforming proxy might, for example, convert 2153 between image formats in order to save cache space or to reduce the 2154 amount of traffic on a slow link. However, operational problems 2155 might occur when these transformations are applied to payloads 2156 intended for critical applications, such as medical imaging or 2157 scientific data analysis, particularly when integrity checks or 2158 digital signatures are used to ensure that the payload received is 2159 identical to the original. 2161 If a proxy receives a request-target with a host name that is not a 2162 fully qualified domain name, it MAY add its own domain to the host 2163 name it received when forwarding the request. A proxy MUST NOT 2164 change the host name if it is a fully qualified domain name. 2166 A proxy MUST NOT modify the "absolute-path" and "query" parts of the 2167 received request-target when forwarding it to the next inbound 2168 server, except as noted above to replace an empty path with "/" or 2169 "*". 2171 A proxy MUST NOT modify header fields that provide information about 2172 the end points of the communication chain, the resource state, or the 2173 selected representation. A proxy MAY change the message body through 2174 application or removal of a transfer coding (Section 4). 2176 A non-transforming proxy MUST preserve the message payload (Section 2177 3.3 of [Part2]). A transforming proxy MUST preserve the payload of a 2178 message that contains the no-transform cache-control directive. 2180 A transforming proxy MAY transform the payload of a message that does 2181 not contain the no-transform cache-control directive; if the payload 2182 is transformed, the transforming proxy MUST add a Warning 214 2183 (Transformation applied) header field if one does not already appear 2184 in the message (see Section 7.5 of [Part6]). 2186 6. Connection Management 2188 HTTP messaging is independent of the underlying transport or session- 2189 layer connection protocol(s). HTTP only presumes a reliable 2190 transport with in-order delivery of requests and the corresponding 2191 in-order delivery of responses. The mapping of HTTP request and 2192 response structures onto the data units of an underlying transport 2193 protocol is outside the scope of this specification. 2195 As described in Section 5.2, the specific connection protocols to be 2196 used for an HTTP interaction are determined by client configuration 2197 and the target URI. For example, the "http" URI scheme 2198 (Section 2.7.1) indicates a default connection of TCP over IP, with a 2199 default TCP port of 80, but the client might be configured to use a 2200 proxy via some other connection, port, or protocol. 2202 HTTP implementations are expected to engage in connection management, 2203 which includes maintaining the state of current connections, 2204 establishing a new connection or reusing an existing connection, 2205 processing messages received on a connection, detecting connection 2206 failures, and closing each connection. Most clients maintain 2207 multiple connections in parallel, including more than one connection 2208 per server endpoint. Most servers are designed to maintain thousands 2209 of concurrent connections, while controlling request queues to enable 2210 fair use and detect denial of service attacks. 2212 6.1. Connection 2214 The "Connection" header field allows the sender to indicate desired 2215 control options for the current connection. In order to avoid 2216 confusing downstream recipients, a proxy or gateway MUST remove or 2217 replace any received connection options before forwarding the 2218 message. 2220 When a header field aside from Connection is used to supply control 2221 information for or about the current connection, the sender MUST list 2222 the corresponding field-name within the "Connection" header field. A 2223 proxy or gateway MUST parse a received Connection header field before 2224 a message is forwarded and, for each connection-option in this field, 2225 remove any header field(s) from the message with the same name as the 2226 connection-option, and then remove the Connection header field itself 2227 (or replace it with the intermediary's own connection options for the 2228 forwarded message). 2230 Hence, the Connection header field provides a declarative way of 2231 distinguishing header fields that are only intended for the immediate 2232 recipient ("hop-by-hop") from those fields that are intended for all 2233 recipients on the chain ("end-to-end"), enabling the message to be 2234 self-descriptive and allowing future connection-specific extensions 2235 to be deployed without fear that they will be blindly forwarded by 2236 older intermediaries. 2238 The Connection header field's value has the following grammar: 2240 Connection = 1#connection-option 2241 connection-option = token 2243 Connection options are case-insensitive. 2245 A sender MUST NOT send a connection option corresponding to a header 2246 field that is intended for all recipients of the payload. For 2247 example, Cache-Control is never appropriate as a connection option 2248 (Section 7.2 of [Part6]). 2250 The connection options do not have to correspond to a header field 2251 present in the message, since a connection-specific header field 2252 might not be needed if there are no parameters associated with that 2253 connection option. Recipients that trigger certain connection 2254 behavior based on the presence of connection options MUST do so based 2255 on the presence of the connection-option rather than only the 2256 presence of the optional header field. In other words, if the 2257 connection option is received as a header field but not indicated 2258 within the Connection field-value, then the recipient MUST ignore the 2259 connection-specific header field because it has likely been forwarded 2260 by an intermediary that is only partially conformant. 2262 When defining new connection options, specifications ought to 2263 carefully consider existing deployed header fields and ensure that 2264 the new connection option does not share the same name as an 2265 unrelated header field that might already be deployed. Defining a 2266 new connection option essentially reserves that potential field-name 2267 for carrying additional information related to the connection option, 2268 since it would be unwise for senders to use that field-name for 2269 anything else. 2271 The "close" connection option is defined for a sender to signal that 2272 this connection will be closed after completion of the response. For 2273 example, 2275 Connection: close 2277 in either the request or the response header fields indicates that 2278 the connection MUST be closed after the current request/response is 2279 complete (Section 6.6). 2281 A client that does not support persistent connections MUST send the 2282 "close" connection option in every request message. 2284 A server that does not support persistent connections MUST send the 2285 "close" connection option in every response message that does not 2286 have a 1xx (Informational) status code. 2288 6.2. Establishment 2290 It is beyond the scope of this specification to describe how 2291 connections are established via various transport or session-layer 2292 protocols. Each connection applies to only one transport link. 2294 6.3. Persistence 2296 HTTP/1.1 defaults to the use of "persistent connections", allowing 2297 multiple requests and responses to be carried over a single 2298 connection. The "close" connection-option is used to signal that a 2299 connection will not persist after the current request/response. HTTP 2300 implementations SHOULD support persistent connections. 2302 A recipient determines whether a connection is persistent or not 2303 based on the most recently received message's protocol version and 2304 Connection header field (if any): 2306 o If the close connection option is present, the connection will not 2307 persist after the current response; else, 2309 o If the received protocol is HTTP/1.1 (or later), the connection 2310 will persist after the current response; else, 2312 o If the received protocol is HTTP/1.0, the "keep-alive" connection 2313 option is present, the recipient is not a proxy, and the recipient 2314 wishes to honor the HTTP/1.0 "keep-alive" mechanism, the 2315 connection will persist after the current response; otherwise, 2317 o The connection will close after the current response. 2319 A server MAY assume that an HTTP/1.1 client intends to maintain a 2320 persistent connection until a close connection option is received in 2321 a request. 2323 A client MAY reuse a persistent connection until it sends or receives 2324 a close connection option or receives an HTTP/1.0 response without a 2325 "keep-alive" connection option. 2327 In order to remain persistent, all messages on a connection MUST have 2328 a self-defined message length (i.e., one not defined by closure of 2329 the connection), as described in Section 3.3. A server MUST read the 2330 entire request message body or close the connection after sending its 2331 response, since otherwise the remaining data on a persistent 2332 connection would be misinterpreted as the next request. Likewise, a 2333 client MUST read the entire response message body if it intends to 2334 reuse the same connection for a subsequent request. 2336 A proxy server MUST NOT maintain a persistent connection with an 2337 HTTP/1.0 client (see Section 19.7.1 of [RFC2068] for information and 2338 discussion of the problems with the Keep-Alive header field 2339 implemented by many HTTP/1.0 clients). 2341 Clients and servers SHOULD NOT assume that a persistent connection is 2342 maintained for HTTP versions less than 1.1 unless it is explicitly 2343 signaled. See Appendix A.1.2 for more information on backward 2344 compatibility with HTTP/1.0 clients. 2346 6.3.1. Retrying Requests 2348 Connections can be closed at any time, with or without intention. 2349 Implementations ought to anticipate the need to recover from 2350 asynchronous close events. 2352 When an inbound connection is closed prematurely, a client MAY open a 2353 new connection and automatically retransmit an aborted sequence of 2354 requests if all of those requests have idempotent methods (Section 2355 4.2.2 of [Part2]). A proxy MUST NOT automatically retry non- 2356 idempotent requests. 2358 A user agent MUST NOT automatically retry a request with a non- 2359 idempotent method unless it has some means to know that the request 2360 semantics are actually idempotent, regardless of the method, or some 2361 means to detect that the original request was never applied. For 2362 example, a user agent that knows (through design or configuration) 2363 that a POST request to a given resource is safe can repeat that 2364 request automatically. Likewise, a user agent designed specifically 2365 to operate on a version control repository might be able to recover 2366 from partial failure conditions by checking the target resource 2367 revision(s) after a failed connection, reverting or fixing any 2368 changes that were partially applied, and then automatically retrying 2369 the requests that failed. 2371 An automatic retry SHOULD NOT be repeated if it fails. 2373 6.3.2. Pipelining 2375 A client that supports persistent connections MAY "pipeline" its 2376 requests (i.e., send multiple requests without waiting for each 2377 response). A server MAY process a sequence of pipelined requests in 2378 parallel if they all have safe methods (Section 4.2.1 of [Part2]), 2379 but MUST send the corresponding responses in the same order that the 2380 requests were received. 2382 A client that pipelines requests MUST be prepared to retry those 2383 requests if the connection closes before it receives all of the 2384 corresponding responses. A client that assumes a persistent 2385 connection and pipelines immediately after connection establishment 2386 MUST NOT pipeline on a retry connection until it knows the connection 2387 is persistent. 2389 Idempotent methods (Section 4.2.2 of [Part2]) are significant to 2390 pipelining because they can be automatically retried after a 2391 connection failure. A user agent SHOULD NOT pipeline requests after 2392 a non-idempotent method until the final response status code for that 2393 method has been received, unless the user agent has a means to detect 2394 and recover from partial failure conditions involving the pipelined 2395 sequence. 2397 An intermediary that receives pipelined requests MAY pipeline those 2398 requests when forwarding them inbound, since it can rely on the 2399 outbound user agent(s) to determine what requests can be safely 2400 pipelined. If the inbound connection fails before receiving a 2401 response, the pipelining intermediary MAY attempt to retry a sequence 2402 of requests that have yet to receive a response if the requests all 2403 have idempotent methods; otherwise, the pipelining intermediary 2404 SHOULD forward any received responses and then close the 2405 corresponding outbound connection(s) so that the outbound user 2406 agent(s) can recover accordingly. 2408 6.4. Concurrency 2410 Clients SHOULD limit the number of simultaneous connections that they 2411 maintain to a given server. 2413 Previous revisions of HTTP gave a specific number of connections as a 2414 ceiling, but this was found to be impractical for many applications. 2415 As a result, this specification does not mandate a particular maximum 2416 number of connections, but instead encourages clients to be 2417 conservative when opening multiple connections. 2419 Multiple connections are typically used to avoid the "head-of-line 2420 blocking" problem, wherein a request that takes significant server- 2421 side processing and/or has a large payload blocks subsequent requests 2422 on the same connection. However, each connection consumes server 2423 resources. Furthermore, using multiple connections can cause 2424 undesirable side effects in congested networks. 2426 Note that servers might reject traffic that they deem abusive, 2427 including an excessive number of connections from a client. 2429 6.5. Failures and Time-outs 2431 Servers will usually have some time-out value beyond which they will 2432 no longer maintain an inactive connection. Proxy servers might make 2433 this a higher value since it is likely that the client will be making 2434 more connections through the same server. The use of persistent 2435 connections places no requirements on the length (or existence) of 2436 this time-out for either the client or the server. 2438 When a client or server wishes to time-out it SHOULD issue a graceful 2439 close on the transport connection. Clients and servers SHOULD both 2440 constantly watch for the other side of the transport close, and 2441 respond to it as appropriate. If a client or server does not detect 2442 the other side's close promptly it could cause unnecessary resource 2443 drain on the network. 2445 A client, server, or proxy MAY close the transport connection at any 2446 time. For example, a client might have started to send a new request 2447 at the same time that the server has decided to close the "idle" 2448 connection. From the server's point of view, the connection is being 2449 closed while it was idle, but from the client's point of view, a 2450 request is in progress. 2452 Servers SHOULD maintain persistent connections and allow the 2453 underlying transport's flow control mechanisms to resolve temporary 2454 overloads, rather than terminate connections with the expectation 2455 that clients will retry. The latter technique can exacerbate network 2456 congestion. 2458 A client sending a message body SHOULD monitor the network connection 2459 for an error status code while it is transmitting the request. If 2460 the client sees an error status code, it SHOULD immediately cease 2461 transmitting the body and close the connection. 2463 6.6. Tear-down 2465 The Connection header field (Section 6.1) provides a "close" 2466 connection option that a sender SHOULD send when it wishes to close 2467 the connection after the current request/response pair. 2469 A client that sends a close connection option MUST NOT send further 2470 requests on that connection (after the one containing close) and MUST 2471 close the connection after reading the final response message 2472 corresponding to this request. 2474 A server that receives a close connection option MUST initiate a 2475 lingering close (see below) of the connection after it sends the 2476 final response to the request that contained close. The server 2477 SHOULD send a close connection option in its final response on that 2478 connection. The server MUST NOT process any further requests 2479 received on that connection. 2481 A server that sends a close connection option MUST initiate a 2482 lingering close of the connection after it sends the response 2483 containing close. The server MUST NOT process any further requests 2484 received on that connection. 2486 A client that receives a close connection option MUST cease sending 2487 requests on that connection and close the connection after reading 2488 the response message containing the close; if additional pipelined 2489 requests had been sent on the connection, the client SHOULD assume 2490 that they will not be processed by the server. 2492 If a server performs an immediate close of a TCP connection, there is 2493 a significant risk that the client will not be able to read the last 2494 HTTP response. If the server receives additional data from the 2495 client on a fully-closed connection, such as another request that was 2496 sent by the client before receiving the server's response, the 2497 server's TCP stack will send a reset packet to the client; 2498 unfortunately, the reset packet might erase the client's 2499 unacknowledged input buffers before they can be read and interpreted 2500 by the client's HTTP parser. 2502 To avoid the TCP reset problem, a server can perform a lingering 2503 close on a connection by closing only the write side of the read/ 2504 write connection (a half-close) and continuing to read from the 2505 connection until the connection is closed by the client or the server 2506 is reasonably certain that its own TCP stack has received the 2507 client's acknowledgement of the packet(s) containing the server's 2508 last response. It is then safe for the server to fully close the 2509 connection. 2511 It is unknown whether the reset problem is exclusive to TCP or might 2512 also be found in other transport connection protocols. 2514 6.7. Upgrade 2516 The "Upgrade" header field is intended to provide a simple mechanism 2517 for transitioning from HTTP/1.1 to some other protocol on the same 2518 connection. A client MAY send a list of protocols in the Upgrade 2519 header field of a request to invite the server to switch to one or 2520 more of those protocols before sending the final response. A server 2521 MUST send an Upgrade header field in 101 (Switching Protocols) 2522 responses to indicate which protocol(s) are being switched to, and 2523 MUST send it in 426 (Upgrade Required) responses to indicate 2524 acceptable protocols. A server MAY send an Upgrade header field in 2525 any other response to indicate that they might be willing to upgrade 2526 to one of the specified protocols for a future request. 2528 Upgrade = 1#protocol 2530 protocol = protocol-name ["/" protocol-version] 2531 protocol-name = token 2532 protocol-version = token 2534 For example, 2536 Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11 2538 Upgrade eases the difficult transition between incompatible protocols 2539 by allowing the client to initiate a request in the more commonly 2540 supported protocol while indicating to the server that it would like 2541 to use a "better" protocol if available (where "better" is determined 2542 by the server, possibly according to the nature of the request method 2543 or target resource). 2545 Upgrade cannot be used to insist on a protocol change; its acceptance 2546 and use by the server is optional. The capabilities and nature of 2547 the application-level communication after the protocol change is 2548 entirely dependent upon the new protocol chosen, although the first 2549 action after changing the protocol MUST be a response to the initial 2550 HTTP request that contained the Upgrade header field. 2552 For example, if the Upgrade header field is received in a GET request 2553 and the server decides to switch protocols, then it first responds 2554 with a 101 (Switching Protocols) message in HTTP/1.1 and then 2555 immediately follows that with the new protocol's equivalent of a 2556 response to a GET on the target resource. This allows a connection 2557 to be upgraded to protocols with the same semantics as HTTP without 2558 the latency cost of an additional round-trip. A server MUST NOT 2559 switch protocols unless the received message semantics can be honored 2560 by the new protocol; an OPTIONS request can be honored by any 2561 protocol. 2563 When Upgrade is sent, a sender MUST also send a Connection header 2564 field (Section 6.1) that contains the "upgrade" connection option, in 2565 order to prevent Upgrade from being accidentally forwarded by 2566 intermediaries that might not implement the listed protocols. A 2567 server MUST ignore an Upgrade header field that is received in an 2568 HTTP/1.0 request. 2570 The Upgrade header field only applies to switching application-level 2571 protocols on the existing connection; it cannot be used to switch to 2572 a protocol on a different connection. For that purpose, it is more 2573 appropriate to use a 3xx (Redirection) response (Section 6.4 of 2574 [Part2]). 2576 This specification only defines the protocol name "HTTP" for use by 2577 the family of Hypertext Transfer Protocols, as defined by the HTTP 2578 version rules of Section 2.6 and future updates to this 2579 specification. Additional tokens ought to be registered with IANA 2580 using the registration procedure defined in Section 7.6. 2582 7. IANA Considerations 2584 7.1. Header Field Registration 2586 HTTP header fields are registered within the Message Header Field 2587 Registry [BCP90] maintained by IANA at . 2590 This document defines the following HTTP header fields, so their 2591 associated registry entries shall be updated according to the 2592 permanent registrations below: 2594 +-------------------+----------+----------+---------------+ 2595 | Header Field Name | Protocol | Status | Reference | 2596 +-------------------+----------+----------+---------------+ 2597 | Connection | http | standard | Section 6.1 | 2598 | Content-Length | http | standard | Section 3.3.2 | 2599 | Host | http | standard | Section 5.4 | 2600 | TE | http | standard | Section 4.3 | 2601 | Trailer | http | standard | Section 4.1.1 | 2602 | Transfer-Encoding | http | standard | Section 3.3.1 | 2603 | Upgrade | http | standard | Section 6.7 | 2604 | Via | http | standard | Section 5.7.1 | 2605 +-------------------+----------+----------+---------------+ 2607 Furthermore, the header field-name "Close" shall be registered as 2608 "reserved", since using that name as an HTTP header field might 2609 conflict with the "close" connection option of the "Connection" 2610 header field (Section 6.1). 2612 +-------------------+----------+----------+-------------+ 2613 | Header Field Name | Protocol | Status | Reference | 2614 +-------------------+----------+----------+-------------+ 2615 | Close | http | reserved | Section 7.1 | 2616 +-------------------+----------+----------+-------------+ 2618 The change controller is: "IETF (iesg@ietf.org) - Internet 2619 Engineering Task Force". 2621 7.2. URI Scheme Registration 2623 IANA maintains the registry of URI Schemes [BCP115] at 2624 . 2626 This document defines the following URI schemes, so their associated 2627 registry entries shall be updated according to the permanent 2628 registrations below: 2630 +------------+------------------------------------+---------------+ 2631 | URI Scheme | Description | Reference | 2632 +------------+------------------------------------+---------------+ 2633 | http | Hypertext Transfer Protocol | Section 2.7.1 | 2634 | https | Hypertext Transfer Protocol Secure | Section 2.7.2 | 2635 +------------+------------------------------------+---------------+ 2637 7.3. Internet Media Type Registration 2639 This document serves as the specification for the Internet media 2640 types "message/http" and "application/http". The following is to be 2641 registered with IANA (see [BCP13]). 2643 7.3.1. Internet Media Type message/http 2645 The message/http type can be used to enclose a single HTTP request or 2646 response message, provided that it obeys the MIME restrictions for 2647 all "message" types regarding line length and encodings. 2649 Type name: message 2651 Subtype name: http 2653 Required parameters: none 2655 Optional parameters: version, msgtype 2657 version: The HTTP-version number of the enclosed message (e.g., 2658 "1.1"). If not present, the version can be determined from the 2659 first line of the body. 2661 msgtype: The message type -- "request" or "response". If not 2662 present, the type can be determined from the first line of the 2663 body. 2665 Encoding considerations: only "7bit", "8bit", or "binary" are 2666 permitted 2668 Security considerations: none 2670 Interoperability considerations: none 2672 Published specification: This specification (see Section 7.3.1). 2674 Applications that use this media type: 2676 Additional information: 2678 Magic number(s): none 2680 File extension(s): none 2682 Macintosh file type code(s): none 2684 Person and email address to contact for further information: See 2685 Authors Section. 2687 Intended usage: COMMON 2688 Restrictions on usage: none 2690 Author/Change controller: IESG 2692 7.3.2. Internet Media Type application/http 2694 The application/http type can be used to enclose a pipeline of one or 2695 more HTTP request or response messages (not intermixed). 2697 Type name: application 2699 Subtype name: http 2701 Required parameters: none 2703 Optional parameters: version, msgtype 2705 version: The HTTP-version number of the enclosed messages (e.g., 2706 "1.1"). If not present, the version can be determined from the 2707 first line of the body. 2709 msgtype: The message type -- "request" or "response". If not 2710 present, the type can be determined from the first line of the 2711 body. 2713 Encoding considerations: HTTP messages enclosed by this type are in 2714 "binary" format; use of an appropriate Content-Transfer-Encoding 2715 is required when transmitted via E-mail. 2717 Security considerations: none 2719 Interoperability considerations: none 2721 Published specification: This specification (see Section 7.3.2). 2723 Applications that use this media type: 2725 Additional information: 2727 Magic number(s): none 2729 File extension(s): none 2731 Macintosh file type code(s): none 2733 Person and email address to contact for further information: See 2734 Authors Section. 2736 Intended usage: COMMON 2738 Restrictions on usage: none 2740 Author/Change controller: IESG 2742 7.4. Transfer Coding Registry 2744 The HTTP Transfer Coding Registry defines the name space for transfer 2745 coding names. 2747 Registrations MUST include the following fields: 2749 o Name 2751 o Description 2753 o Pointer to specification text 2755 Names of transfer codings MUST NOT overlap with names of content 2756 codings (Section 3.1.2.1 of [Part2]) unless the encoding 2757 transformation is identical, as is the case for the compression 2758 codings defined in Section 4.2. 2760 Values to be added to this name space require IETF Review (see 2761 Section 4.1 of [RFC5226]), and MUST conform to the purpose of 2762 transfer coding defined in this section. Use of program names for 2763 the identification of encoding formats is not desirable and is 2764 discouraged for future encodings. 2766 The registry itself is maintained at 2767 . 2769 7.5. Transfer Coding Registration 2771 The HTTP Transfer Coding Registry shall be updated with the 2772 registrations below: 2774 +----------+----------------------------------------+---------------+ 2775 | Name | Description | Reference | 2776 +----------+----------------------------------------+---------------+ 2777 | chunked | Transfer in a series of chunks | Section 4.1 | 2778 | compress | UNIX "compress" program method | Section 4.2.1 | 2779 | deflate | "deflate" compression mechanism | Section 4.2.2 | 2780 | | ([RFC1951]) used inside the "zlib" | | 2781 | | data format ([RFC1950]) | | 2782 | gzip | Same as GNU zip [RFC1952] | Section 4.2.3 | 2783 +----------+----------------------------------------+---------------+ 2785 7.6. Upgrade Token Registry 2787 The HTTP Upgrade Token Registry defines the name space for protocol- 2788 name tokens used to identify protocols in the Upgrade header field. 2789 Each registered protocol name is associated with contact information 2790 and an optional set of specifications that details how the connection 2791 will be processed after it has been upgraded. 2793 Registrations happen on a "First Come First Served" basis (see 2794 Section 4.1 of [RFC5226]) and are subject to the following rules: 2796 1. A protocol-name token, once registered, stays registered forever. 2798 2. The registration MUST name a responsible party for the 2799 registration. 2801 3. The registration MUST name a point of contact. 2803 4. The registration MAY name a set of specifications associated with 2804 that token. Such specifications need not be publicly available. 2806 5. The registration SHOULD name a set of expected "protocol-version" 2807 tokens associated with that token at the time of registration. 2809 6. The responsible party MAY change the registration at any time. 2810 The IANA will keep a record of all such changes, and make them 2811 available upon request. 2813 7. The IESG MAY reassign responsibility for a protocol token. This 2814 will normally only be used in the case when a responsible party 2815 cannot be contacted. 2817 This registration procedure for HTTP Upgrade Tokens replaces that 2818 previously defined in Section 7.2 of [RFC2817]. 2820 7.7. Upgrade Token Registration 2822 The HTTP Upgrade Token Registry shall be updated with the 2823 registration below: 2825 +-------+----------------------+----------------------+-------------+ 2826 | Value | Description | Expected Version | Reference | 2827 | | | Tokens | | 2828 +-------+----------------------+----------------------+-------------+ 2829 | HTTP | Hypertext Transfer | any DIGIT.DIGIT | Section 2.6 | 2830 | | Protocol | (e.g, "2.0") | | 2831 +-------+----------------------+----------------------+-------------+ 2833 The responsible party is: "IETF (iesg@ietf.org) - Internet 2834 Engineering Task Force". 2836 8. Security Considerations 2838 This section is meant to inform developers, information providers, 2839 and users of known security concerns relevant to HTTP/1.1 message 2840 syntax, parsing, and routing. 2842 8.1. DNS-related Attacks 2844 HTTP clients rely heavily on the Domain Name Service (DNS), and are 2845 thus generally prone to security attacks based on the deliberate 2846 misassociation of IP addresses and DNS names not protected by DNSSEC. 2847 Clients need to be cautious in assuming the validity of an IP number/ 2848 DNS name association unless the response is protected by DNSSEC 2849 ([RFC4033]). 2851 8.2. Intermediaries and Caching 2853 By their very nature, HTTP intermediaries are men-in-the-middle, and 2854 represent an opportunity for man-in-the-middle attacks. Compromise 2855 of the systems on which the intermediaries run can result in serious 2856 security and privacy problems. Intermediaries have access to 2857 security-related information, personal information about individual 2858 users and organizations, and proprietary information belonging to 2859 users and content providers. A compromised intermediary, or an 2860 intermediary implemented or configured without regard to security and 2861 privacy considerations, might be used in the commission of a wide 2862 range of potential attacks. 2864 Intermediaries that contain a shared cache are especially vulnerable 2865 to cache poisoning attacks. 2867 Implementers need to consider the privacy and security implications 2868 of their design and coding decisions, and of the configuration 2869 options they provide to operators (especially the default 2870 configuration). 2872 Users need to be aware that intermediaries are no more trustworthy 2873 than the people who run them; HTTP itself cannot solve this problem. 2875 8.3. Buffer Overflows 2877 Because HTTP uses mostly textual, character-delimited fields, 2878 attackers can overflow buffers in implementations, and/or perform a 2879 Denial of Service against implementations that accept fields with 2880 unlimited lengths. 2882 To promote interoperability, this specification makes specific 2883 recommendations for minimum size limits on request-line 2884 (Section 3.1.1) and blocks of header fields (Section 3.2). These are 2885 minimum recommendations, chosen to be supportable even by 2886 implementations with limited resources; it is expected that most 2887 implementations will choose substantially higher limits. 2889 This specification also provides a way for servers to reject messages 2890 that have request-targets that are too long (Section 6.5.12 of 2891 [Part2]) or request entities that are too large (Section 6.5 of 2892 [Part2]). 2894 Recipients SHOULD carefully limit the extent to which they read other 2895 fields, including (but not limited to) request methods, response 2896 status phrases, header field-names, and body chunks, so as to avoid 2897 denial of service attacks without impeding interoperability. 2899 8.4. Message Integrity 2901 HTTP does not define a specific mechanism for ensuring message 2902 integrity, instead relying on the error-detection ability of 2903 underlying transport protocols and the use of length or chunk- 2904 delimited framing to detect completeness. Additional integrity 2905 mechanisms, such as hash functions or digital signatures applied to 2906 the content, can be selectively added to messages via extensible 2907 metadata header fields. Historically, the lack of a single integrity 2908 mechanism has been justified by the informal nature of most HTTP 2909 communication. However, the prevalence of HTTP as an information 2910 access mechanism has resulted in its increasing use within 2911 environments where verification of message integrity is crucial. 2913 User agents are encouraged to implement configurable means for 2914 detecting and reporting failures of message integrity such that those 2915 means can be enabled within environments for which integrity is 2916 necessary. For example, a browser being used to view medical history 2917 or drug interaction information needs to indicate to the user when 2918 such information is detected by the protocol to be incomplete, 2919 expired, or corrupted during transfer. Such mechanisms might be 2920 selectively enabled via user agent extensions or the presence of 2921 message integrity metadata in a response. At a minimum, user agents 2922 ought to provide some indication that allows a user to distinguish 2923 between a complete and incomplete response message (Section 3.4) when 2924 such verification is desired. 2926 8.5. Server Log Information 2928 A server is in the position to save personal data about a user's 2929 requests over time, which might identify their reading patterns or 2930 subjects of interest. In particular, log information gathered at an 2931 intermediary often contains a history of user agent interaction, 2932 across a multitude of sites, that can be traced to individual users. 2934 HTTP log information is confidential in nature; its handling is often 2935 constrained by laws and regulations. Log information needs to be 2936 securely stored and appropriate guidelines followed for its analysis. 2937 Anonymization of personal information within individual entries 2938 helps, but is generally not sufficient to prevent real log traces 2939 from being re-identified based on correlation with other access 2940 characteristics. As such, access traces that are keyed to a specific 2941 client should not be published even if the key is pseudonymous. 2943 To minimize the risk of theft or accidental publication, log 2944 information should be purged of personally identifiable information, 2945 including user identifiers, IP addresses, and user-provided query 2946 parameters, as soon as that information is no longer necessary to 2947 support operational needs for security, auditing, or fraud control. 2949 9. Acknowledgments 2951 This edition of HTTP/1.1 builds on the many contributions that went 2952 into RFC 1945, RFC 2068, RFC 2145, and RFC 2616, including 2953 substantial contributions made by the previous authors, editors, and 2954 working group chairs: Tim Berners-Lee, Ari Luotonen, Roy T. Fielding, 2955 Henrik Frystyk Nielsen, Jim Gettys, Jeffrey C. Mogul, Larry Masinter, 2956 and Paul J. Leach. Mark Nottingham oversaw this effort as working 2957 group chair. 2959 Since 1999, the following contributors have helped improve the HTTP 2960 specification by reporting bugs, asking smart questions, drafting or 2961 reviewing text, and evaluating open issues: 2963 Adam Barth, Adam Roach, Addison Phillips, Adrian Chadd, Adrien W. de 2964 Croy, Alan Ford, Alan Ruttenberg, Albert Lunde, Alek Storm, Alex 2965 Rousskov, Alexandre Morgaut, Alexey Melnikov, Alisha Smith, Amichai 2966 Rothman, Amit Klein, Amos Jeffries, Andreas Maier, Andreas Petersson, 2967 Anil Sharma, Anne van Kesteren, Anthony Bryan, Asbjorn Ulsberg, Ashok 2968 Kumar, Balachander Krishnamurthy, Barry Leiba, Ben Laurie, Benjamin 2969 Niven-Jenkins, Bil Corry, Bill Burke, Bjoern Hoehrmann, Bob 2970 Scheifler, Boris Zbarsky, Brett Slatkin, Brian Kell, Brian McBarron, 2971 Brian Pane, Brian Smith, Bryce Nesbitt, Cameron Heavon-Jones, Carl 2972 Kugler, Carsten Bormann, Charles Fry, Chris Newman, Chris Weber, 2973 Cyrus Daboo, Dale Robert Anderson, Dan Wing, Dan Winship, Daniel 2974 Stenberg, Darrel Miller, Dave Cridland, Dave Crocker, Dave Kristol, 2975 David Booth, David Singer, David W. Morris, Diwakar Shetty, Dmitry 2976 Kurochkin, Drummond Reed, Duane Wessels, Duncan Cragg, Edward Lee, 2977 Eliot Lear, Eran Hammer-Lahav, Eric D. Williams, Eric J. Bowman, Eric 2978 Lawrence, Eric Rescorla, Erik Aronesty, Evan Prodromou, Florian 2979 Weimer, Frank Ellermann, Fred Bohle, Gabriel Montenegro, Geoffrey 2980 Sneddon, Gervase Markham, Grahame Grieve, Greg Wilkins, Harald Tveit 2981 Alvestrand, Harry Halpin, Helge Hess, Henrik Nordstrom, Henry S. 2982 Thompson, Henry Story, Herbert van de Sompel, Howard Melman, Hugo 2983 Haas, Ian Fette, Ian Hickson, Ido Safruti, Ilya Grigorik, Ingo 2984 Struck, J. Ross Nicoll, James H. Manger, James Lacey, James M. Snell, 2985 Jamie Lokier, Jan Algermissen, Jeff Hodges (who came up with the term 2986 'effective Request-URI'), Jeff Walden, Jeroen de Borst, Jim Luther, 2987 Joe D. Williams, Joe Gregorio, Joe Orton, John C. Klensin, John C. 2988 Mallery, John Cowan, John Kemp, John Panzer, John Schneider, John 2989 Stracke, John Sullivan, Jonas Sicking, Jonathan A. Rees, Jonathan 2990 Billington, Jonathan Moore, Jonathan Rees, Jonathan Silvera, Jordi 2991 Ros, Joris Dobbelsteen, Josh Cohen, Julien Pierre, Jungshik Shin, 2992 Justin Chapweske, Justin Erenkrantz, Justin James, Kalvinder Singh, 2993 Karl Dubost, Keith Hoffman, Keith Moore, Ken Murchison, Koen Holtman, 2994 Konstantin Voronkov, Kris Zyp, Lisa Dusseault, Maciej Stachowiak, 2995 Marc Schneider, Marc Slemko, Mark Baker, Mark Pauley, Mark Watson, 2996 Markus Isomaki, Markus Lanthaler, Martin J. Duerst, Martin Musatov, 2997 Martin Nilsson, Martin Thomson, Matt Lynch, Matthew Cox, Max Clark, 2998 Michael Burrows, Michael Hausenblas, Mike Amundsen, Mike Belshe, Mike 2999 Kelly, Mike Schinkel, Miles Sabin, Murray S. Kucherawy, Mykyta 3000 Yevstifeyev, Nathan Rixham, Nicholas Shanks, Nico Williams, Nicolas 3001 Alvarez, Nicolas Mailhot, Noah Slater, Pablo Castro, Pat Hayes, 3002 Patrick R. McManus, Patrik Faltstrom, Paul E. Jones, Paul Hoffman, 3003 Paul Marquess, Peter Lepeska, Peter Saint-Andre, Peter Watkins, Phil 3004 Archer, Philippe Mougin, Phillip Hallam-Baker, Poul-Henning Kamp, 3005 Preethi Natarajan, Rajeev Bector, Ray Polk, Reto Bachmann-Gmuer, 3006 Richard Cyganiak, Robert Brewer, Robert Collins, Robert O'Callahan, 3007 Robert Olofsson, Robert Sayre, Robert Siemer, Robert de Wilde, 3008 Roberto Javier Godoy, Roberto Peon, Roland Zink, Ronny Widjaja, S. 3009 Mike Dierken, Salvatore Loreto, Sam Johnston, Sam Ruby, Scott 3010 Lawrence (who maintained the original issues list), Sean B. Palmer, 3011 Shane McCarron, Stefan Eissing, Stefan Tilkov, Stefanos Harhalakis, 3012 Stephane Bortzmeyer, Stephen Farrell, Stephen Ludin, Stuart Williams, 3013 Subbu Allamaraju, Subramanian Moonesamy, Sylvain Hellegouarch, Tapan 3014 Divekar, Tatsuya Hayashi, Ted Hardie, Thomas Broyer, Thomas Fossati, 3015 Thomas Nordin, Thomas Roessler, Tim Bray, Tim Morgan, Tim Olsen, 3016 Tobias Oberstein, Tom Zhou, Travis Snoozy, Tyler Close, Vincent 3017 Murphy, Wenbo Zhu, Werner Baumann, Wilbur Streett, Wilfredo Sanchez 3018 Vega, William A. Rowe Jr., William Chan, Willy Tarreau, Xiaoshu Wang, 3019 Yaron Goland, Yngve Nysaeter Pettersen, Yoav Nir, Yogesh Bang, Yutaka 3020 Oiwa, Yves Lafon (long-time member of the editor team), Zed A. Shaw, 3021 and Zhong Yu. 3023 See Section 16 of [RFC2616] for additional acknowledgements from 3024 prior revisions. 3026 10. References 3028 10.1. Normative References 3030 [Part2] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext 3031 Transfer Protocol (HTTP/1.1): Semantics and Content", 3032 draft-ietf-httpbis-p2-semantics-22 (work in progress), 3033 February 2013. 3035 [Part4] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext 3036 Transfer Protocol (HTTP/1.1): Conditional Requests", 3037 draft-ietf-httpbis-p4-conditional-22 (work in 3038 progress), February 2013. 3040 [Part5] Fielding, R., Ed., Lafon, Y., Ed., and J. Reschke, Ed., 3041 "Hypertext Transfer Protocol (HTTP/1.1): Range 3042 Requests", draft-ietf-httpbis-p5-range-22 (work in 3043 progress), February 2013. 3045 [Part6] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke, 3046 Ed., "Hypertext Transfer Protocol (HTTP/1.1): Caching", 3047 draft-ietf-httpbis-p6-cache-22 (work in progress), 3048 February 2013. 3050 [Part7] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext 3051 Transfer Protocol (HTTP/1.1): Authentication", 3052 draft-ietf-httpbis-p7-auth-22 (work in progress), 3053 February 2013. 3055 [RFC1950] Deutsch, L. and J-L. Gailly, "ZLIB Compressed Data 3056 Format Specification version 3.3", RFC 1950, May 1996. 3058 [RFC1951] Deutsch, P., "DEFLATE Compressed Data Format 3059 Specification version 1.3", RFC 1951, May 1996. 3061 [RFC1952] Deutsch, P., Gailly, J-L., Adler, M., Deutsch, L., and 3062 G. Randers-Pehrson, "GZIP file format specification 3063 version 4.3", RFC 1952, May 1996. 3065 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3066 Requirement Levels", BCP 14, RFC 2119, March 1997. 3068 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, 3069 "Uniform Resource Identifier (URI): Generic Syntax", 3070 STD 66, RFC 3986, January 2005. 3072 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for 3073 Syntax Specifications: ABNF", STD 68, RFC 5234, 3074 January 2008. 3076 [USASCII] American National Standards Institute, "Coded Character 3077 Set -- 7-bit American Standard Code for Information 3078 Interchange", ANSI X3.4, 1986. 3080 10.2. Informative References 3082 [BCP115] Hansen, T., Hardie, T., and L. Masinter, "Guidelines 3083 and Registration Procedures for New URI Schemes", 3084 BCP 115, RFC 4395, February 2006. 3086 [BCP13] Freed, N., Klensin, J., and T. Hansen, "Media Type 3087 Specifications and Registration Procedures", BCP 13, 3088 RFC 6838, January 2013. 3090 [BCP90] Klyne, G., Nottingham, M., and J. Mogul, "Registration 3091 Procedures for Message Header Fields", BCP 90, 3092 RFC 3864, September 2004. 3094 [ISO-8859-1] International Organization for Standardization, 3095 "Information technology -- 8-bit single-byte coded 3096 graphic character sets -- Part 1: Latin alphabet No. 3097 1", ISO/IEC 8859-1:1998, 1998. 3099 [Kri2001] Kristol, D., "HTTP Cookies: Standards, Privacy, and 3100 Politics", ACM Transactions on Internet Technology Vol. 3101 1, #2, November 2001, 3102 . 3104 [RFC1919] Chatel, M., "Classical versus Transparent IP Proxies", 3105 RFC 1919, March 1996. 3107 [RFC1945] Berners-Lee, T., Fielding, R., and H. Nielsen, 3108 "Hypertext Transfer Protocol -- HTTP/1.0", RFC 1945, 3109 May 1996. 3111 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet 3112 Mail Extensions (MIME) Part One: Format of Internet 3113 Message Bodies", RFC 2045, November 1996. 3115 [RFC2047] Moore, K., "MIME (Multipurpose Internet Mail 3116 Extensions) Part Three: Message Header Extensions for 3117 Non-ASCII Text", RFC 2047, November 1996. 3119 [RFC2068] Fielding, R., Gettys, J., Mogul, J., Nielsen, H., and 3120 T. Berners-Lee, "Hypertext Transfer Protocol -- 3121 HTTP/1.1", RFC 2068, January 1997. 3123 [RFC2145] Mogul, J., Fielding, R., Gettys, J., and H. Nielsen, 3124 "Use and Interpretation of HTTP Version Numbers", 3125 RFC 2145, May 1997. 3127 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 3128 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 3129 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999. 3131 [RFC2817] Khare, R. and S. Lawrence, "Upgrading to TLS Within 3132 HTTP/1.1", RFC 2817, May 2000. 3134 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, May 2000. 3136 [RFC3040] Cooper, I., Melve, I., and G. Tomlinson, "Internet Web 3137 Replication and Caching Taxonomy", RFC 3040, 3138 January 2001. 3140 [RFC4033] Arends, R., Austein, R., Larson, M., Massey, D., and S. 3141 Rose, "DNS Security Introduction and Requirements", 3142 RFC 4033, March 2005. 3144 [RFC4559] Jaganathan, K., Zhu, L., and J. Brezak, "SPNEGO-based 3145 Kerberos and NTLM HTTP Authentication in Microsoft 3146 Windows", RFC 4559, June 2006. 3148 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing 3149 an IANA Considerations Section in RFCs", BCP 26, 3150 RFC 5226, May 2008. 3152 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer 3153 Security (TLS) Protocol Version 1.2", RFC 5246, 3154 August 2008. 3156 [RFC5322] Resnick, P., "Internet Message Format", RFC 5322, 3157 October 2008. 3159 [RFC6265] Barth, A., "HTTP State Management Mechanism", RFC 6265, 3160 April 2011. 3162 Appendix A. HTTP Version History 3164 HTTP has been in use by the World-Wide Web global information 3165 initiative since 1990. The first version of HTTP, later referred to 3166 as HTTP/0.9, was a simple protocol for hypertext data transfer across 3167 the Internet with only a single request method (GET) and no metadata. 3168 HTTP/1.0, as defined by [RFC1945], added a range of request methods 3169 and MIME-like messaging that could include metadata about the data 3170 transferred and modifiers on the request/response semantics. 3171 However, HTTP/1.0 did not sufficiently take into consideration the 3172 effects of hierarchical proxies, caching, the need for persistent 3173 connections, or name-based virtual hosts. The proliferation of 3174 incompletely-implemented applications calling themselves "HTTP/1.0" 3175 further necessitated a protocol version change in order for two 3176 communicating applications to determine each other's true 3177 capabilities. 3179 HTTP/1.1 remains compatible with HTTP/1.0 by including more stringent 3180 requirements that enable reliable implementations, adding only those 3181 new features that will either be safely ignored by an HTTP/1.0 3182 recipient or only sent when communicating with a party advertising 3183 conformance with HTTP/1.1. 3185 It is beyond the scope of a protocol specification to mandate 3186 conformance with previous versions. HTTP/1.1 was deliberately 3187 designed, however, to make supporting previous versions easy. We 3188 would expect a general-purpose HTTP/1.1 server to understand any 3189 valid request in the format of HTTP/1.0 and respond appropriately 3190 with an HTTP/1.1 message that only uses features understood (or 3191 safely ignored) by HTTP/1.0 clients. Likewise, we would expect an 3192 HTTP/1.1 client to understand any valid HTTP/1.0 response. 3194 Since HTTP/0.9 did not support header fields in a request, there is 3195 no mechanism for it to support name-based virtual hosts (selection of 3196 resource by inspection of the Host header field). Any server that 3197 implements name-based virtual hosts ought to disable support for 3198 HTTP/0.9. Most requests that appear to be HTTP/0.9 are, in fact, 3199 badly constructed HTTP/1.x requests wherein a buggy client failed to 3200 properly encode linear whitespace found in a URI reference and placed 3201 in the request-target. 3203 A.1. Changes from HTTP/1.0 3205 This section summarizes major differences between versions HTTP/1.0 3206 and HTTP/1.1. 3208 A.1.1. Multi-homed Web Servers 3210 The requirements that clients and servers support the Host header 3211 field (Section 5.4), report an error if it is missing from an 3212 HTTP/1.1 request, and accept absolute URIs (Section 5.3) are among 3213 the most important changes defined by HTTP/1.1. 3215 Older HTTP/1.0 clients assumed a one-to-one relationship of IP 3216 addresses and servers; there was no other established mechanism for 3217 distinguishing the intended server of a request than the IP address 3218 to which that request was directed. The Host header field was 3219 introduced during the development of HTTP/1.1 and, though it was 3220 quickly implemented by most HTTP/1.0 browsers, additional 3221 requirements were placed on all HTTP/1.1 requests in order to ensure 3222 complete adoption. At the time of this writing, most HTTP-based 3223 services are dependent upon the Host header field for targeting 3224 requests. 3226 A.1.2. Keep-Alive Connections 3228 In HTTP/1.0, each connection is established by the client prior to 3229 the request and closed by the server after sending the response. 3230 However, some implementations implement the explicitly negotiated 3231 ("Keep-Alive") version of persistent connections described in Section 3232 19.7.1 of [RFC2068]. 3234 Some clients and servers might wish to be compatible with these 3235 previous approaches to persistent connections, by explicitly 3236 negotiating for them with a "Connection: keep-alive" request header 3237 field. However, some experimental implementations of HTTP/1.0 3238 persistent connections are faulty; for example, if an HTTP/1.0 proxy 3239 server doesn't understand Connection, it will erroneously forward 3240 that header field to the next inbound server, which would result in a 3241 hung connection. 3243 One attempted solution was the introduction of a Proxy-Connection 3244 header field, targeted specifically at proxies. In practice, this 3245 was also unworkable, because proxies are often deployed in multiple 3246 layers, bringing about the same problem discussed above. 3248 As a result, clients are encouraged not to send the Proxy-Connection 3249 header field in any requests. 3251 Clients are also encouraged to consider the use of Connection: keep- 3252 alive in requests carefully; while they can enable persistent 3253 connections with HTTP/1.0 servers, clients using them need will need 3254 to monitor the connection for "hung" requests (which indicate that 3255 the client ought stop sending the header field), and this mechanism 3256 ought not be used by clients at all when a proxy is being used. 3258 A.1.3. Introduction of Transfer-Encoding 3260 HTTP/1.1 introduces the Transfer-Encoding header field 3261 (Section 3.3.1). Transfer codings need to be decoded prior to 3262 forwarding an HTTP message over a MIME-compliant protocol. 3264 A.2. Changes from RFC 2616 3266 HTTP's approach to error handling has been explained. (Section 2.5) 3268 The expectation to support HTTP/0.9 requests has been removed. 3270 The term "Effective Request URI" has been introduced. (Section 5.5) 3272 HTTP messages can be (and often are) buffered by implementations; 3273 despite it sometimes being available as a stream, HTTP is 3274 fundamentally a message-oriented protocol. (Section 3) 3276 Minimum supported sizes for various protocol elements have been 3277 suggested, to improve interoperability. 3279 Header fields that span multiple lines ("line folding") are 3280 deprecated. (Section 3.2.4) 3282 The HTTP-version ABNF production has been clarified to be case- 3283 sensitive. Additionally, version numbers has been restricted to 3284 single digits, due to the fact that implementations are known to 3285 handle multi-digit version numbers incorrectly. (Section 2.6) 3287 The HTTPS URI scheme is now defined by this specification; 3288 previously, it was done in Section 2.4 of [RFC2818]. (Section 2.7.2) 3290 The HTTPS URI scheme implies end-to-end security. (Section 2.7.2) 3292 Userinfo (i.e., username and password) are now disallowed in HTTP and 3293 HTTPS URIs, because of security issues related to their transmission 3294 on the wire. (Section 2.7.1) 3296 Invalid whitespace around field-names is now required to be rejected, 3297 because accepting it represents a security vulnerability. 3298 (Section 3.2) 3299 The ABNF productions defining header fields now only list the field 3300 value. (Section 3.2) 3302 Rules about implicit linear whitespace between certain grammar 3303 productions have been removed; now whitespace is only allowed where 3304 specifically defined in the ABNF. (Section 3.2.3) 3306 The NUL octet is no longer allowed in comment and quoted-string text, 3307 and handling of backslash-escaping in them has been clarified. 3308 (Section 3.2.6) 3310 The quoted-pair rule no longer allows escaping control characters 3311 other than HTAB. (Section 3.2.6) 3313 Non-ASCII content in header fields and the reason phrase has been 3314 obsoleted and made opaque (the TEXT rule was removed). 3315 (Section 3.2.6) 3317 Bogus "Content-Length" header fields are now required to be handled 3318 as errors by recipients. (Section 3.3.2) 3320 The "identity" transfer coding token has been removed. (Sections 3.3 3321 and 4) 3323 The algorithm for determining the message body length has been 3324 clarified to indicate all of the special cases (e.g., driven by 3325 methods or status codes) that affect it, and that new protocol 3326 elements cannot define such special cases. (Section 3.3.3) 3328 "multipart/byteranges" is no longer a way of determining message body 3329 length detection. (Section 3.3.3) 3331 CONNECT is a new, special case in determining message body length. 3332 (Section 3.3.3) 3334 Chunk length does not include the count of the octets in the chunk 3335 header and trailer. (Section 4.1) 3337 Use of chunk extensions is deprecated, and line folding in them is 3338 disallowed. (Section 4.1) 3340 The segment + query components of RFC3986 have been used to define 3341 the request-target, instead of abs_path from RFC 1808. (Section 5.3) 3343 The asterisk form of the request-target is only allowed in the 3344 OPTIONS method. (Section 5.3) 3346 Exactly when "close" connection options have to be sent has been 3347 clarified. (Section 6.1) 3349 "hop-by-hop" header fields are required to appear in the Connection 3350 header field; just because they're defined as hop-by-hop in this 3351 specification doesn't exempt them. (Section 6.1) 3353 The limit of two connections per server has been removed. 3354 (Section 6.3) 3356 An idempotent sequence of requests is no longer required to be 3357 retried. (Section 6.3) 3359 The requirement to retry requests under certain circumstances when 3360 the server prematurely closes the connection has been removed. 3361 (Section 6.3) 3363 Some extraneous requirements about when servers are allowed to close 3364 connections prematurely have been removed. (Section 6.3) 3366 The semantics of the Upgrade header field is now defined in responses 3367 other than 101 (this was incorporated from [RFC2817]). (Section 6.7) 3369 Registration of Transfer Codings now requires IETF Review 3370 (Section 7.4) 3372 The meaning of the "deflate" content coding has been clarified. 3373 (Section 4.2.2) 3375 This specification now defines the Upgrade Token Registry, previously 3376 defined in Section 7.2 of [RFC2817]. (Section 7.6) 3378 Empty list elements in list productions (e.g., a list header 3379 containing ", ,") have been deprecated. (Appendix B) 3381 Issues with the Keep-Alive and Proxy-Connection headers in requests 3382 are pointed out, with use of the latter being discouraged altogether. 3383 (Appendix A.1.2) 3385 Appendix B. ABNF list extension: #rule 3387 A #rule extension to the ABNF rules of [RFC5234] is used to improve 3388 readability in the definitions of some header field values. 3390 A construct "#" is defined, similar to "*", for defining comma- 3391 delimited lists of elements. The full form is "#element" 3392 indicating at least and at most elements, each separated by a 3393 single comma (",") and optional whitespace (OWS). 3395 Thus, 3397 1#element => element *( OWS "," OWS element ) 3399 and: 3401 #element => [ 1#element ] 3403 and for n >= 1 and m > 1: 3405 #element => element *( OWS "," OWS element ) 3407 For compatibility with legacy list rules, recipients SHOULD accept 3408 empty list elements. In other words, consumers would follow the list 3409 productions: 3411 #element => [ ( "," / element ) *( OWS "," [ OWS element ] ) ] 3413 1#element => *( "," OWS ) element *( OWS "," [ OWS element ] ) 3415 Note that empty elements do not contribute to the count of elements 3416 present, though. 3418 For example, given these ABNF productions: 3420 example-list = 1#example-list-elmt 3421 example-list-elmt = token ; see Section 3.2.6 3423 Then these are valid values for example-list (not including the 3424 double quotes, which are present for delimitation only): 3426 "foo,bar" 3427 "foo ,bar," 3428 "foo , ,bar,charlie " 3430 But these values would be invalid, as at least one non-empty element 3431 is required: 3433 "" 3434 "," 3435 ", ," 3437 Appendix C shows the collected ABNF, with the list rules expanded as 3438 explained above. 3440 Appendix C. Collected ABNF 3442 BWS = OWS 3443 Connection = *( "," OWS ) connection-option *( OWS "," [ OWS 3444 connection-option ] ) 3445 Content-Length = 1*DIGIT 3447 HTTP-message = start-line *( header-field CRLF ) CRLF [ message-body 3448 ] 3449 HTTP-name = %x48.54.54.50 ; HTTP 3450 HTTP-version = HTTP-name "/" DIGIT "." DIGIT 3451 Host = uri-host [ ":" port ] 3453 OWS = *( SP / HTAB ) 3455 RWS = 1*( SP / HTAB ) 3457 TE = [ ( "," / t-codings ) *( OWS "," [ OWS t-codings ] ) ] 3458 Trailer = *( "," OWS ) field-name *( OWS "," [ OWS field-name ] ) 3459 Transfer-Encoding = *( "," OWS ) transfer-coding *( OWS "," [ OWS 3460 transfer-coding ] ) 3462 URI-reference = 3463 Upgrade = *( "," OWS ) protocol *( OWS "," [ OWS protocol ] ) 3465 Via = *( "," OWS ) ( received-protocol RWS received-by [ RWS comment 3466 ] ) *( OWS "," [ OWS ( received-protocol RWS received-by [ RWS 3467 comment ] ) ] ) 3469 absolute-URI = 3470 absolute-form = absolute-URI 3471 absolute-path = 1*( "/" segment ) 3472 asterisk-form = "*" 3473 attribute = token 3474 authority = 3475 authority-form = authority 3477 chunk = chunk-size [ chunk-ext ] CRLF chunk-data CRLF 3478 chunk-data = 1*OCTET 3479 chunk-ext = *( ";" chunk-ext-name [ "=" chunk-ext-val ] ) 3480 chunk-ext-name = token 3481 chunk-ext-val = token / quoted-str-nf 3482 chunk-size = 1*HEXDIG 3483 chunked-body = *chunk last-chunk trailer-part CRLF 3484 comment = "(" *( ctext / quoted-cpair / comment ) ")" 3485 connection-option = token 3486 ctext = HTAB / SP / %x21-27 ; '!'-''' 3487 / %x2A-5B ; '*'-'[' 3488 / %x5D-7E ; ']'-'~' 3489 / obs-text 3491 field-content = *( HTAB / SP / VCHAR / obs-text ) 3492 field-name = token 3493 field-value = *( field-content / obs-fold ) 3495 header-field = field-name ":" OWS field-value BWS 3496 http-URI = "http://" authority path-abempty [ "?" query ] 3497 https-URI = "https://" authority path-abempty [ "?" query ] 3499 last-chunk = 1*"0" [ chunk-ext ] CRLF 3501 message-body = *OCTET 3502 method = token 3504 obs-fold = CRLF ( SP / HTAB ) 3505 obs-text = %x80-FF 3506 origin-form = absolute-path [ "?" query ] 3508 partial-URI = relative-part [ "?" query ] 3509 path-abempty = 3510 port = 3511 protocol = protocol-name [ "/" protocol-version ] 3512 protocol-name = token 3513 protocol-version = token 3514 pseudonym = token 3516 qdtext = HTAB / SP / "!" / %x23-5B ; '#'-'[' 3517 / %x5D-7E ; ']'-'~' 3518 / obs-text 3519 qdtext-nf = HTAB / SP / "!" / %x23-5B ; '#'-'[' 3520 / %x5D-7E ; ']'-'~' 3521 / obs-text 3522 query = 3523 quoted-cpair = "\" ( HTAB / SP / VCHAR / obs-text ) 3524 quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) 3525 quoted-str-nf = DQUOTE *( qdtext-nf / quoted-pair ) DQUOTE 3526 quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE 3528 rank = ( "0" [ "." *3DIGIT ] ) / ( "1" [ "." *3"0" ] ) 3529 reason-phrase = *( HTAB / SP / VCHAR / obs-text ) 3530 received-by = ( uri-host [ ":" port ] ) / pseudonym 3531 received-protocol = [ protocol-name "/" ] protocol-version 3532 relative-part = 3533 request-line = method SP request-target SP HTTP-version CRLF 3534 request-target = origin-form / absolute-form / authority-form / 3535 asterisk-form 3537 segment = 3538 special = "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" / 3539 DQUOTE / "/" / "[" / "]" / "?" / "=" / "{" / "}" 3540 start-line = request-line / status-line 3541 status-code = 3DIGIT 3542 status-line = HTTP-version SP status-code SP reason-phrase CRLF 3544 t-codings = "trailers" / ( transfer-coding [ t-ranking ] ) 3545 t-ranking = OWS ";" OWS "q=" rank 3546 tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / 3547 "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA 3548 token = 1*tchar 3549 trailer-part = *( header-field CRLF ) 3550 transfer-coding = "chunked" / "compress" / "deflate" / "gzip" / 3551 transfer-extension 3552 transfer-extension = token *( OWS ";" OWS transfer-parameter ) 3553 transfer-parameter = attribute BWS "=" BWS value 3555 uri-host = 3557 value = word 3559 word = token / quoted-string 3561 Appendix D. Change Log (to be removed by RFC Editor before publication) 3563 D.1. Since RFC 2616 3565 Changes up to the first Working Group Last Call draft are summarized 3566 in . 3569 D.2. Since draft-ietf-httpbis-p1-messaging-21 3571 Closed issues: 3573 o : "Cite HTTPS 3574 URI scheme definition" (the spec now includes the HTTPs scheme 3575 definition and thus updates RFC 2818) 3577 o : "mention of 3578 'proxies' in section about caches" 3580 o : "use of ABNF 3581 terms from RFC 3986" 3583 o : "editorial 3584 improvements to message length definition" 3586 o : "Connection 3587 header field MUST vs SHOULD" 3589 o : "editorial 3590 improvements to persistent connections section" 3592 o : "URI 3593 normalization vs empty path" 3595 o : "p1 feedback" 3597 o : "is parsing 3598 OBS-FOLD mandatory?" 3600 o : "HTTPS and 3601 Shared Caching" 3603 o : "Requirements 3604 for recipients of ws between start-line and first header field" 3606 o : "SP and HT 3607 when being tolerant" 3609 o : "Message 3610 Parsing Strictness" 3612 o : "'Render'" 3614 o : "No-Transform" 3616 o : "p2 editorial 3617 feedback" 3619 o : "Content- 3620 Length SHOULD be sent" 3622 o : "origin-form 3623 does not allow path starting with "//"" 3625 o : "ambiguity in 3626 part 1 example" 3628 Index 3630 A 3631 absolute-form (of request-target) 40 3632 accelerator 10 3633 application/http Media Type 58 3634 asterisk-form (of request-target) 41 3635 authority-form (of request-target) 41 3637 B 3638 browser 7 3640 C 3641 cache 11 3642 cacheable 12 3643 captive portal 11 3644 chunked (Coding Format) 27, 30, 34 3645 client 7 3646 close 48, 53 3647 compress (Coding Format) 37 3648 connection 7 3649 Connection header field 48, 53 3650 Content-Length header field 28 3652 D 3653 deflate (Coding Format) 37 3654 downstream 9 3656 E 3657 effective request URI 43 3659 G 3660 gateway 10 3661 Grammar 3662 absolute-form 40 3663 absolute-path 16 3664 absolute-URI 16 3665 ALPHA 6 3666 asterisk-form 40 3667 attribute 34 3668 authority 16 3669 authority-form 40 3670 BWS 24 3671 chunk 35 3672 chunk-data 35 3673 chunk-ext 35 3674 chunk-ext-name 35 3675 chunk-ext-val 35 3676 chunk-size 35 3677 chunked-body 35 3678 comment 26 3679 Connection 48 3680 connection-option 48 3681 Content-Length 29 3682 CR 6 3683 CRLF 6 3684 ctext 26 3685 CTL 6 3686 date2 34 3687 date3 34 3688 DIGIT 6 3689 DQUOTE 6 3690 field-content 22 3691 field-name 22 3692 field-value 22 3693 header-field 22 3694 HEXDIG 6 3695 Host 42 3696 HTAB 6 3697 HTTP-message 19 3698 HTTP-name 13 3699 http-URI 16 3700 HTTP-version 13 3701 https-URI 18 3702 last-chunk 35 3703 LF 6 3704 message-body 26 3705 method 20 3706 obs-fold 22 3707 obs-text 26 3708 OCTET 6 3709 origin-form 40 3710 OWS 24 3711 partial-URI 16 3712 port 16 3713 protocol-name 45 3714 protocol-version 45 3715 pseudonym 45 3716 qdtext 26 3717 qdtext-nf 35 3718 query 16 3719 quoted-cpair 26 3720 quoted-pair 26 3721 quoted-str-nf 35 3722 quoted-string 26 3723 rank 37 3724 reason-phrase 21 3725 received-by 45 3726 received-protocol 45 3727 request-line 20 3728 request-target 40 3729 RWS 24 3730 segment 16 3731 SP 6 3732 special 25 3733 start-line 20 3734 status-code 21 3735 status-line 21 3736 t-codings 37 3737 t-ranking 37 3738 tchar 25 3739 TE 37 3740 token 25 3741 Trailer 35 3742 trailer-part 35 3743 transfer-coding 34 3744 Transfer-Encoding 27 3745 transfer-extension 34 3746 transfer-parameter 34 3747 Upgrade 54 3748 uri-host 16 3749 URI-reference 16 3750 value 34 3751 VCHAR 6 3752 Via 45 3753 word 25 3754 gzip (Coding Format) 37 3756 H 3757 header field 19 3758 header section 19 3759 headers 19 3760 Host header field 41 3761 http URI scheme 16 3762 https URI scheme 17 3764 I 3765 inbound 9 3766 interception proxy 11 3767 intermediary 9 3769 M 3770 Media Type 3771 application/http 58 3772 message/http 57 3773 message 7 3774 message/http Media Type 57 3775 method 20 3777 N 3778 non-transforming proxy 10 3780 O 3781 origin server 7 3782 origin-form (of request-target) 40 3783 outbound 9 3785 P 3786 proxy 10 3788 R 3789 recipient 7 3790 request 7 3791 request-target 20 3792 resource 15 3793 response 7 3794 reverse proxy 10 3796 S 3797 sender 7 3798 server 7 3799 spider 7 3801 T 3802 target resource 38 3803 target URI 38 3804 TE header field 37 3805 Trailer header field 35 3806 Transfer-Encoding header field 27 3807 transforming proxy 10 3808 transparent proxy 11 3809 tunnel 11 3811 U 3812 Upgrade header field 54 3813 upstream 9 3814 URI scheme 3815 http 16 3816 https 17 3817 user agent 7 3819 V 3820 Via header field 45 3822 Authors' Addresses 3824 Roy T. Fielding (editor) 3825 Adobe Systems Incorporated 3826 345 Park Ave 3827 San Jose, CA 95110 3828 USA 3830 EMail: fielding@gbiv.com 3831 URI: http://roy.gbiv.com/ 3833 Julian F. Reschke (editor) 3834 greenbytes GmbH 3835 Hafenweg 16 3836 Muenster, NW 48155 3837 Germany 3839 EMail: julian.reschke@greenbytes.de 3840 URI: http://greenbytes.de/tech/webdav/