idnits 2.17.1 draft-fielding-httpbis-http-messaging-00.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 : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to contain a disclaimer for pre-RFC5378 work, but was first submitted on or after 10 November 2008. The disclaimer is usually necessary only for documents that revise or obsolete older RFCs, and that take significant amounts of text from those RFCs. If you can contact all authors of the source material and they are willing to grant the BCP78 rights to the IETF Trust, 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 (March 5, 2018) is 2244 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: 'RFC2145' is defined on line 3463, but no explicit reference was found in the text ** Obsolete normative reference: RFC 793 (Obsoleted by RFC 9293) ** 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' -- Possible downref: Non-RFC (?) normative reference: ref. 'Welch' -- 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) -- Obsolete informational reference (is this intentional?): RFC 7230 (Obsoleted by RFC 9110, RFC 9112) Summary: 4 errors (**), 0 flaws (~~), 3 warnings (==), 12 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group R. Fielding, Ed. 3 Internet-Draft Adobe 4 Obsoletes: 7230 (if approved) J. Reschke, Ed. 5 Intended status: Standards Track greenbytes 6 Expires: September 6, 2018 March 5, 2018 8 Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing 9 draft-fielding-httpbis-http-messaging-00 11 Abstract 13 The Hypertext Transfer Protocol (HTTP) is a stateless application- 14 level protocol for distributed, collaborative, hypertext information 15 systems. This document provides an overview of HTTP architecture and 16 its associated terminology, defines the "http" and "https" Uniform 17 Resource Identifier (URI) schemes, defines the HTTP/1.1 message 18 syntax and parsing requirements, and describes related security 19 concerns for implementations. 21 This document obsoletes RFC 7230. 23 Editorial Note 25 This note is to be removed before publishing as an RFC. 27 _This is a temporary document for the purpose of planning the 28 revisions of RFCs 7230 to 7235. This is not yet an official work 29 item of the HTTP Working Group._ 31 Discussion of this draft takes place on the HTTP working group 32 mailing list (ietf-http-wg@w3.org), which is archived at 33 . 35 Errata for RFC 7230 have been collected at , and an additional issues list 37 lives at . 39 The changes in this draft are summarized in Appendix C.1. 41 Status of This Memo 43 This Internet-Draft is submitted in full conformance with the 44 provisions of BCP 78 and BCP 79. 46 Internet-Drafts are working documents of the Internet Engineering 47 Task Force (IETF). Note that other groups may also distribute 48 working documents as Internet-Drafts. The list of current Internet- 49 Drafts is at https://datatracker.ietf.org/drafts/current/. 51 Internet-Drafts are draft documents valid for a maximum of six months 52 and may be updated, replaced, or obsoleted by other documents at any 53 time. It is inappropriate to use Internet-Drafts as reference 54 material or to cite them other than as "work in progress." 56 This Internet-Draft will expire on September 6, 2018. 58 Copyright Notice 60 Copyright (c) 2018 IETF Trust and the persons identified as the 61 document authors. All rights reserved. 63 This document is subject to BCP 78 and the IETF Trust's Legal 64 Provisions Relating to IETF Documents 65 (https://trustee.ietf.org/license-info) in effect on the date of 66 publication of this document. Please review these documents 67 carefully, as they describe your rights and restrictions with respect 68 to this document. Code Components extracted from this document must 69 include Simplified BSD License text as described in Section 4.e of 70 the Trust Legal Provisions and are provided without warranty as 71 described in the Simplified BSD License. 73 This document may contain material from IETF Documents or IETF 74 Contributions published or made publicly available before November 75 10, 2008. The person(s) controlling the copyright in some of this 76 material may not have granted the IETF Trust the right to allow 77 modifications of such material outside the IETF Standards Process. 78 Without obtaining an adequate license from the person(s) controlling 79 the copyright in such materials, this document may not be modified 80 outside the IETF Standards Process, and derivative works of it may 81 not be created outside the IETF Standards Process, except to format 82 it for publication as an RFC or to translate it into languages other 83 than English. 85 Table of Contents 87 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 5 88 1.1. Requirements Notation . . . . . . . . . . . . . . . . . . 6 89 1.2. Syntax Notation . . . . . . . . . . . . . . . . . . . . . 6 90 2. Architecture . . . . . . . . . . . . . . . . . . . . . . . . 6 91 2.1. Client/Server Messaging . . . . . . . . . . . . . . . . . 7 92 2.2. Implementation Diversity . . . . . . . . . . . . . . . . 8 93 2.3. Intermediaries . . . . . . . . . . . . . . . . . . . . . 9 94 2.4. Caches . . . . . . . . . . . . . . . . . . . . . . . . . 11 95 2.5. Conformance and Error Handling . . . . . . . . . . . . . 12 96 2.6. Protocol Versioning . . . . . . . . . . . . . . . . . . . 13 97 2.7. Uniform Resource Identifiers . . . . . . . . . . . . . . 16 98 2.7.1. http URI Scheme . . . . . . . . . . . . . . . . . . . 16 99 2.7.2. https URI Scheme . . . . . . . . . . . . . . . . . . 18 100 2.7.3. http and https URI Normalization and Comparison . . . 19 101 3. Message Format . . . . . . . . . . . . . . . . . . . . . . . 19 102 3.1. Start Line . . . . . . . . . . . . . . . . . . . . . . . 20 103 3.1.1. Request Line . . . . . . . . . . . . . . . . . . . . 21 104 3.1.2. Status Line . . . . . . . . . . . . . . . . . . . . . 22 105 3.2. Header Fields . . . . . . . . . . . . . . . . . . . . . . 22 106 3.2.1. Field Extensibility . . . . . . . . . . . . . . . . . 23 107 3.2.2. Field Order . . . . . . . . . . . . . . . . . . . . . 23 108 3.2.3. Whitespace . . . . . . . . . . . . . . . . . . . . . 24 109 3.2.4. Field Parsing . . . . . . . . . . . . . . . . . . . . 24 110 3.2.5. Field Limits . . . . . . . . . . . . . . . . . . . . 26 111 3.2.6. Field Value Components . . . . . . . . . . . . . . . 26 112 3.3. Message Body . . . . . . . . . . . . . . . . . . . . . . 27 113 3.3.1. Transfer-Encoding . . . . . . . . . . . . . . . . . . 28 114 3.3.2. Content-Length . . . . . . . . . . . . . . . . . . . 29 115 3.3.3. Message Body Length . . . . . . . . . . . . . . . . . 31 116 3.4. Handling Incomplete Messages . . . . . . . . . . . . . . 33 117 3.5. Message Parsing Robustness . . . . . . . . . . . . . . . 34 118 4. Transfer Codings . . . . . . . . . . . . . . . . . . . . . . 34 119 4.1. Chunked Transfer Coding . . . . . . . . . . . . . . . . . 35 120 4.1.1. Chunk Extensions . . . . . . . . . . . . . . . . . . 36 121 4.1.2. Chunked Trailer Part . . . . . . . . . . . . . . . . 36 122 4.1.3. Decoding Chunked . . . . . . . . . . . . . . . . . . 37 123 4.2. Compression Codings . . . . . . . . . . . . . . . . . . . 37 124 4.2.1. Compress Coding . . . . . . . . . . . . . . . . . . . 38 125 4.2.2. Deflate Coding . . . . . . . . . . . . . . . . . . . 38 126 4.2.3. Gzip Coding . . . . . . . . . . . . . . . . . . . . . 38 127 4.3. TE . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 128 4.4. Trailer . . . . . . . . . . . . . . . . . . . . . . . . . 39 129 5. Message Routing . . . . . . . . . . . . . . . . . . . . . . . 39 130 5.1. Identifying a Target Resource . . . . . . . . . . . . . . 40 131 5.2. Connecting Inbound . . . . . . . . . . . . . . . . . . . 40 132 5.3. Request Target . . . . . . . . . . . . . . . . . . . . . 41 133 5.3.1. origin-form . . . . . . . . . . . . . . . . . . . . . 41 134 5.3.2. absolute-form . . . . . . . . . . . . . . . . . . . . 41 135 5.3.3. authority-form . . . . . . . . . . . . . . . . . . . 42 136 5.3.4. asterisk-form . . . . . . . . . . . . . . . . . . . . 42 137 5.4. Host . . . . . . . . . . . . . . . . . . . . . . . . . . 43 138 5.5. Effective Request URI . . . . . . . . . . . . . . . . . . 44 139 5.6. Associating a Response to a Request . . . . . . . . . . . 46 140 5.7. Message Forwarding . . . . . . . . . . . . . . . . . . . 46 141 5.7.1. Via . . . . . . . . . . . . . . . . . . . . . . . . . 46 142 5.7.2. Transformations . . . . . . . . . . . . . . . . . . . 48 143 6. Connection Management . . . . . . . . . . . . . . . . . . . . 49 144 6.1. Connection . . . . . . . . . . . . . . . . . . . . . . . 50 145 6.2. Establishment . . . . . . . . . . . . . . . . . . . . . . 51 146 6.3. Persistence . . . . . . . . . . . . . . . . . . . . . . . 51 147 6.3.1. Retrying Requests . . . . . . . . . . . . . . . . . . 52 148 6.3.2. Pipelining . . . . . . . . . . . . . . . . . . . . . 53 149 6.4. Concurrency . . . . . . . . . . . . . . . . . . . . . . . 54 150 6.5. Failures and Timeouts . . . . . . . . . . . . . . . . . . 54 151 6.6. Tear-down . . . . . . . . . . . . . . . . . . . . . . . . 55 152 6.7. Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . 56 153 7. ABNF List Extension: #rule . . . . . . . . . . . . . . . . . 58 154 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 59 155 8.1. Header Field Registration . . . . . . . . . . . . . . . . 59 156 8.2. URI Scheme Registration . . . . . . . . . . . . . . . . . 60 157 8.3. Internet Media Type Registration . . . . . . . . . . . . 60 158 8.3.1. Internet Media Type message/http . . . . . . . . . . 61 159 8.3.2. Internet Media Type application/http . . . . . . . . 62 160 8.4. Transfer Coding Registry . . . . . . . . . . . . . . . . 63 161 8.4.1. Procedure . . . . . . . . . . . . . . . . . . . . . . 63 162 8.4.2. Registration . . . . . . . . . . . . . . . . . . . . 64 163 8.5. Content Coding Registration . . . . . . . . . . . . . . . 64 164 8.6. Upgrade Token Registry . . . . . . . . . . . . . . . . . 65 165 8.6.1. Procedure . . . . . . . . . . . . . . . . . . . . . . 65 166 8.6.2. Upgrade Token Registration . . . . . . . . . . . . . 65 167 9. Security Considerations . . . . . . . . . . . . . . . . . . . 66 168 9.1. Establishing Authority . . . . . . . . . . . . . . . . . 66 169 9.2. Risks of Intermediaries . . . . . . . . . . . . . . . . . 67 170 9.3. Attacks via Protocol Element Length . . . . . . . . . . . 67 171 9.4. Response Splitting . . . . . . . . . . . . . . . . . . . 68 172 9.5. Request Smuggling . . . . . . . . . . . . . . . . . . . . 69 173 9.6. Message Integrity . . . . . . . . . . . . . . . . . . . . 69 174 9.7. Message Confidentiality . . . . . . . . . . . . . . . . . 70 175 9.8. Privacy of Server Log Information . . . . . . . . . . . . 70 176 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 70 177 10.1. Normative References . . . . . . . . . . . . . . . . . . 70 178 10.2. Informative References . . . . . . . . . . . . . . . . . 72 179 Appendix A. HTTP Version History . . . . . . . . . . . . . . . . 75 180 A.1. Changes from HTTP/1.0 . . . . . . . . . . . . . . . . . . 75 181 A.1.1. Multihomed Web Servers . . . . . . . . . . . . . . . 75 182 A.1.2. Keep-Alive Connections . . . . . . . . . . . . . . . 76 183 A.1.3. Introduction of Transfer-Encoding . . . . . . . . . . 76 184 A.2. Changes from RFC 7230 . . . . . . . . . . . . . . . . . . 77 185 Appendix B. Collected ABNF . . . . . . . . . . . . . . . . . . . 77 186 Appendix C. Change Log . . . . . . . . . . . . . . . . . . . . . 79 187 C.1. Since RFC 7230 . . . . . . . . . . . . . . . . . . . . . 79 188 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 189 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 84 190 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 84 192 1. Introduction 194 The Hypertext Transfer Protocol (HTTP) is a stateless application- 195 level request/response protocol that uses extensible semantics and 196 self-descriptive message payloads for flexible interaction with 197 network-based hypertext information systems. This document is the 198 first in a series of documents that collectively form the HTTP/1.1 199 specification: 201 1. "Message Syntax and Routing" (this document) 203 2. "Semantics and Content" [SEMNTCS] 205 3. "Conditional Requests" [CONDTNL] 207 4. "Range Requests" [RANGERQ] 209 5. "Caching" [CACHING] 211 6. "Authentication" [AUTHFRM] 213 This specification obsoletes RFC 7230, with the changes being 214 summarized in Appendix A.2. 216 HTTP is a generic interface protocol for information systems. It is 217 designed to hide the details of how a service is implemented by 218 presenting a uniform interface to clients that is independent of the 219 types of resources provided. Likewise, servers do not need to be 220 aware of each client's purpose: an HTTP request can be considered in 221 isolation rather than being associated with a specific type of client 222 or a predetermined sequence of application steps. The result is a 223 protocol that can be used effectively in many different contexts and 224 for which implementations can evolve independently over time. 226 HTTP is also designed for use as an intermediation protocol for 227 translating communication to and from non-HTTP information systems. 228 HTTP proxies and gateways can provide access to alternative 229 information services by translating their diverse protocols into a 230 hypertext format that can be viewed and manipulated by clients in the 231 same way as HTTP services. 233 One consequence of this flexibility is that the protocol cannot be 234 defined in terms of what occurs behind the interface. Instead, we 235 are limited to defining the syntax of communication, the intent of 236 received communication, and the expected behavior of recipients. If 237 the communication is considered in isolation, then successful actions 238 ought to be reflected in corresponding changes to the observable 239 interface provided by servers. However, since multiple clients might 240 act in parallel and perhaps at cross-purposes, we cannot require that 241 such changes be observable beyond the scope of a single response. 243 This document describes the architectural elements that are used or 244 referred to in HTTP, defines the "http" and "https" URI schemes, 245 describes overall network operation and connection management, and 246 defines HTTP message framing and forwarding requirements. Our goal 247 is to define all of the mechanisms necessary for HTTP message 248 handling that are independent of message semantics, thereby defining 249 the complete set of requirements for message parsers and message- 250 forwarding intermediaries. 252 1.1. Requirements Notation 254 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 255 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 256 document are to be interpreted as described in [RFC2119]. 258 Conformance criteria and considerations regarding error handling are 259 defined in Section 2.5. 261 1.2. Syntax Notation 263 This specification uses the Augmented Backus-Naur Form (ABNF) 264 notation of [RFC5234] with a list extension, defined in Section 7, 265 that allows for compact definition of comma-separated lists using a 266 '#' operator (similar to how the '*' operator indicates repetition). 267 Appendix B shows the collected grammar with all list operators 268 expanded to standard ABNF notation. 270 The following core rules are included by reference, as defined in 271 [RFC5234], Appendix B.1: ALPHA (letters), CR (carriage return), CRLF 272 (CR LF), CTL (controls), DIGIT (decimal 0-9), DQUOTE (double quote), 273 HEXDIG (hexadecimal 0-9/A-F/a-f), HTAB (horizontal tab), LF (line 274 feed), OCTET (any 8-bit sequence of data), SP (space), and VCHAR (any 275 visible [USASCII] character). 277 As a convention, ABNF rule names prefixed with "obs-" denote 278 "obsolete" grammar rules that appear for historical reasons. 280 2. Architecture 282 HTTP was created for the World Wide Web (WWW) architecture and has 283 evolved over time to support the scalability needs of a worldwide 284 hypertext system. Much of that architecture is reflected in the 285 terminology and syntax productions used to define HTTP. 287 2.1. Client/Server Messaging 289 HTTP is a stateless request/response protocol that operates by 290 exchanging messages (Section 3) across a reliable transport- or 291 session-layer "connection" (Section 6). An HTTP "client" is a 292 program that establishes a connection to a server for the purpose of 293 sending one or more HTTP requests. An HTTP "server" is a program 294 that accepts connections in order to service HTTP requests by sending 295 HTTP responses. 297 The terms "client" and "server" refer only to the roles that these 298 programs perform for a particular connection. The same program might 299 act as a client on some connections and a server on others. The term 300 "user agent" refers to any of the various client programs that 301 initiate a request, including (but not limited to) browsers, spiders 302 (web-based robots), command-line tools, custom applications, and 303 mobile apps. The term "origin server" refers to the program that can 304 originate authoritative responses for a given target resource. The 305 terms "sender" and "recipient" refer to any implementation that sends 306 or receives a given message, respectively. 308 HTTP relies upon the Uniform Resource Identifier (URI) standard 309 [RFC3986] to indicate the target resource (Section 5.1) and 310 relationships between resources. Messages are passed in a format 311 similar to that used by Internet mail [RFC5322] and the Multipurpose 312 Internet Mail Extensions (MIME) [RFC2045] (see Appendix A of 313 [SEMNTCS] for the differences between HTTP and MIME messages). 315 Most HTTP communication consists of a retrieval request (GET) for a 316 representation of some resource identified by a URI. In the simplest 317 case, this might be accomplished via a single bidirectional 318 connection (===) between the user agent (UA) and the origin server 319 (O). 321 request > 322 UA ======================================= O 323 < response 325 A client sends an HTTP request to a server in the form of a request 326 message, beginning with a request-line that includes a method, URI, 327 and protocol version (Section 3.1.1), followed by header fields 328 containing request modifiers, client information, and representation 329 metadata (Section 3.2), an empty line to indicate the end of the 330 header section, and finally a message body containing the payload 331 body (if any, Section 3.3). 333 A server responds to a client's request by sending one or more HTTP 334 response messages, each beginning with a status line that includes 335 the protocol version, a success or error code, and textual reason 336 phrase (Section 3.1.2), possibly followed by header fields containing 337 server information, resource metadata, and representation metadata 338 (Section 3.2), an empty line to indicate the end of the header 339 section, and finally a message body containing the payload body (if 340 any, Section 3.3). 342 A connection might be used for multiple request/response exchanges, 343 as defined in Section 6.3. 345 The following example illustrates a typical message exchange for a 346 GET request (Section 4.3.1 of [SEMNTCS]) on the URI 347 "http://www.example.com/hello.txt": 349 Client request: 351 GET /hello.txt HTTP/1.1 352 User-Agent: curl/7.16.3 libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3 353 Host: www.example.com 354 Accept-Language: en, mi 356 Server response: 358 HTTP/1.1 200 OK 359 Date: Mon, 27 Jul 2009 12:28:53 GMT 360 Server: Apache 361 Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT 362 ETag: "34aa387-d-1568eb00" 363 Accept-Ranges: bytes 364 Content-Length: 51 365 Vary: Accept-Encoding 366 Content-Type: text/plain 368 Hello World! My payload includes a trailing CRLF. 370 2.2. Implementation Diversity 372 When considering the design of HTTP, it is easy to fall into a trap 373 of thinking that all user agents are general-purpose browsers and all 374 origin servers are large public websites. That is not the case in 375 practice. Common HTTP user agents include household appliances, 376 stereos, scales, firmware update scripts, command-line programs, 377 mobile apps, and communication devices in a multitude of shapes and 378 sizes. Likewise, common HTTP origin servers include home automation 379 units, configurable networking components, office machines, 380 autonomous robots, news feeds, traffic cameras, ad selectors, and 381 video-delivery platforms. 383 The term "user agent" does not imply that there is a human user 384 directly interacting with the software agent at the time of a 385 request. In many cases, a user agent is installed or configured to 386 run in the background and save its results for later inspection (or 387 save only a subset of those results that might be interesting or 388 erroneous). Spiders, for example, are typically given a start URI 389 and configured to follow certain behavior while crawling the Web as a 390 hypertext graph. 392 The implementation diversity of HTTP means that not all user agents 393 can make interactive suggestions to their user or provide adequate 394 warning for security or privacy concerns. In the few cases where 395 this specification requires reporting of errors to the user, it is 396 acceptable for such reporting to only be observable in an error 397 console or log file. Likewise, requirements that an automated action 398 be confirmed by the user before proceeding might be met via advance 399 configuration choices, run-time options, or simple avoidance of the 400 unsafe action; confirmation does not imply any specific user 401 interface or interruption of normal processing if the user has 402 already made that choice. 404 2.3. Intermediaries 406 HTTP enables the use of intermediaries to satisfy requests through a 407 chain of connections. There are three common forms of HTTP 408 intermediary: proxy, gateway, and tunnel. In some cases, a single 409 intermediary might act as an origin server, proxy, gateway, or 410 tunnel, switching behavior based on the nature of each request. 412 > > > > 413 UA =========== A =========== B =========== C =========== O 414 < < < < 416 The figure above shows three intermediaries (A, B, and C) between the 417 user agent and origin server. A request or response message that 418 travels the whole chain will pass through four separate connections. 419 Some HTTP communication options might apply only to the connection 420 with the nearest, non-tunnel neighbor, only to the endpoints of the 421 chain, or to all connections along the chain. Although the diagram 422 is linear, each participant might be engaged in multiple, 423 simultaneous communications. For example, B might be receiving 424 requests from many clients other than A, and/or forwarding requests 425 to servers other than C, at the same time that it is handling A's 426 request. Likewise, later requests might be sent through a different 427 path of connections, often based on dynamic configuration for load 428 balancing. 430 The terms "upstream" and "downstream" are used to describe 431 directional requirements in relation to the message flow: all 432 messages flow from upstream to downstream. The terms "inbound" and 433 "outbound" are used to describe directional requirements in relation 434 to the request route: "inbound" means toward the origin server and 435 "outbound" means toward the user agent. 437 A "proxy" is a message-forwarding agent that is selected by the 438 client, usually via local configuration rules, to receive requests 439 for some type(s) of absolute URI and attempt to satisfy those 440 requests via translation through the HTTP interface. Some 441 translations are minimal, such as for proxy requests for "http" URIs, 442 whereas other requests might require translation to and from entirely 443 different application-level protocols. Proxies are often used to 444 group an organization's HTTP requests through a common intermediary 445 for the sake of security, annotation services, or shared caching. 446 Some proxies are designed to apply transformations to selected 447 messages or payloads while they are being forwarded, as described in 448 Section 5.7.2. 450 A "gateway" (a.k.a. "reverse proxy") is an intermediary that acts as 451 an origin server for the outbound connection but translates received 452 requests and forwards them inbound to another server or servers. 453 Gateways are often used to encapsulate legacy or untrusted 454 information services, to improve server performance through 455 "accelerator" caching, and to enable partitioning or load balancing 456 of HTTP services across multiple machines. 458 All HTTP requirements applicable to an origin server also apply to 459 the outbound communication of a gateway. A gateway communicates with 460 inbound 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 ought to conform to user agent requirements 464 on the gateway's inbound connection. 466 A "tunnel" acts as a blind relay between two connections without 467 changing the messages. Once active, a tunnel is not considered a 468 party to the HTTP communication, though the tunnel might have been 469 initiated by an HTTP request. A tunnel ceases to exist when both 470 ends of the relayed connection are closed. Tunnels are used to 471 extend a virtual connection through an intermediary, such as when 472 Transport Layer Security (TLS, [RFC5246]) is used to establish 473 confidential communication through a shared firewall proxy. 475 The above categories for intermediary only consider those acting as 476 participants in the HTTP communication. There are also 477 intermediaries that can act on lower layers of the network protocol 478 stack, filtering or redirecting HTTP traffic without the knowledge or 479 permission of message senders. Network intermediaries are 480 indistinguishable (at a protocol level) from a man-in-the-middle 481 attack, often introducing security flaws or interoperability problems 482 due to mistakenly violating HTTP semantics. 484 For example, an "interception proxy" [RFC3040] (also commonly known 485 as a "transparent proxy" [RFC1919] or "captive portal") differs from 486 an HTTP proxy because it is not selected by the client. Instead, an 487 interception proxy filters or redirects outgoing TCP port 80 packets 488 (and occasionally other common port traffic). Interception proxies 489 are commonly found on public network access points, as a means of 490 enforcing account subscription prior to allowing use of non-local 491 Internet services, and within corporate firewalls to enforce network 492 usage policies. 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, a 498 server 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 [CACHING]. 531 There is a wide variety of architectures and configurations of caches 532 deployed across the World Wide Web and inside large organizations. 533 These include national hierarchies of proxy caches to save 534 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. 556 Conformance includes both the syntax and semantics of protocol 557 elements. A sender MUST NOT generate protocol elements that convey a 558 meaning that is known by that sender to be false. A sender MUST NOT 559 generate protocol elements that do not match the grammar defined by 560 the corresponding ABNF rules. Within a given message, a sender MUST 561 NOT generate protocol elements or syntax alternatives that are only 562 allowed to be generated by participants in other roles (i.e., a role 563 that the sender does not have for that message). 565 When a received protocol element is parsed, the recipient MUST be 566 able to parse any value of reasonable length that is applicable to 567 the recipient's role and that matches the grammar defined by the 568 corresponding ABNF rules. Note, however, that some received protocol 569 elements might not be parsed. For example, an intermediary 570 forwarding a message might parse a header-field into generic field- 571 name and field-value components, but then forward the header field 572 without further parsing inside the field-value. 574 HTTP does not have specific length limitations for many of its 575 protocol elements because the lengths that might be appropriate will 576 vary widely, depending on the deployment context and purpose of the 577 implementation. Hence, interoperability between senders and 578 recipients depends on shared expectations regarding what is a 579 reasonable length for each protocol element. Furthermore, what is 580 commonly understood to be a reasonable length for some protocol 581 elements has changed over the course of the past two decades of HTTP 582 use and is expected to continue changing in the future. 584 At a minimum, a recipient MUST be able to parse and process protocol 585 element lengths that are at least as long as the values that it 586 generates for those same protocol elements in other messages. For 587 example, an origin server that publishes very long URI references to 588 its own resources needs to be able to parse and process those same 589 references when received as a request target. 591 A recipient MUST interpret a received protocol element according to 592 the semantics defined for it by this specification, including 593 extensions to this specification, unless the recipient has determined 594 (through experience or configuration) that the sender incorrectly 595 implements what is implied by those semantics. For example, an 596 origin server might disregard the contents of a received Accept- 597 Encoding header field if inspection of the User-Agent header field 598 indicates a specific implementation version that is known to fail on 599 receipt of certain content codings. 601 Unless noted otherwise, a recipient MAY attempt to recover a usable 602 protocol element from an invalid construct. HTTP does not define 603 specific error handling mechanisms except when they have a direct 604 impact on security, since different applications of the protocol 605 require different error handling strategies. For example, a Web 606 browser might wish to transparently recover from a response where the 607 Location header field doesn't parse according to the ABNF, whereas a 608 systems control client might consider any form of error recovery to 609 be dangerous. 611 2.6. Protocol Versioning 613 HTTP uses a "." numbering scheme to indicate versions 614 of the protocol. This specification defines version "1.1". The 615 protocol version as a whole indicates the sender's conformance with 616 the set of requirements laid out in that version's corresponding 617 specification of HTTP. 619 The version of an HTTP message is indicated by an HTTP-version field 620 in the first line of the message. HTTP-version is case-sensitive. 622 HTTP-version = HTTP-name "/" DIGIT "." DIGIT 623 HTTP-name = %x48.54.54.50 ; "HTTP", case-sensitive 625 The HTTP version number consists of two decimal digits separated by a 626 "." (period or decimal point). The first digit ("major version") 627 indicates the HTTP messaging syntax, whereas the second digit ("minor 628 version") indicates the highest minor version within that major 629 version to which the sender is conformant and able to understand for 630 future communication. The minor version advertises the sender's 631 communication capabilities even when the sender is only using a 632 backwards-compatible subset of the protocol, thereby letting the 633 recipient know that more advanced features can be used in response 634 (by servers) or in future requests (by clients). 636 When an HTTP/1.1 message is sent to an HTTP/1.0 recipient [RFC1945] 637 or a recipient whose version is unknown, the HTTP/1.1 message is 638 constructed such that it can be interpreted as a valid HTTP/1.0 639 message if all of the newer features are ignored. This specification 640 places recipient-version requirements on some new features so that a 641 conformant sender will only use compatible features until it has 642 determined, through configuration or the receipt of a message, that 643 the recipient supports HTTP/1.1. 645 The interpretation of a header field does not change between minor 646 versions of the same major HTTP version, though the default behavior 647 of a recipient in the absence of such a field can change. Unless 648 specified otherwise, header fields defined in HTTP/1.1 are defined 649 for all versions of HTTP/1.x. In particular, the Host and Connection 650 header fields ought to be implemented by all HTTP/1.x implementations 651 whether or not they advertise conformance with HTTP/1.1. 653 New header fields can be introduced without changing the protocol 654 version if their defined semantics allow them to be safely ignored by 655 recipients that do not recognize them. Header field extensibility is 656 discussed in Section 3.2.1. 658 Intermediaries that process HTTP messages (i.e., all intermediaries 659 other than those acting as tunnels) MUST send their own HTTP-version 660 in forwarded messages. In other words, they are not allowed to 661 blindly forward the first line of an HTTP message without ensuring 662 that the protocol version in that message matches a version to which 663 that intermediary is conformant for both the receiving and sending of 664 messages. Forwarding an HTTP message without rewriting the HTTP- 665 version might result in communication errors when downstream 666 recipients use the message sender's version to determine what 667 features are safe to use for later communication with that sender. 669 A client SHOULD send a request version equal to the highest version 670 to which the client is conformant and whose major version is no 671 higher than the highest version supported by the server, if this is 672 known. A client MUST NOT send a version to which it is not 673 conformant. 675 A client MAY send a lower request version if it is known that the 676 server incorrectly implements the HTTP specification, but only after 677 the client has attempted at least one normal request and determined 678 from the response status code or header fields (e.g., Server) that 679 the server improperly handles higher request versions. 681 A server SHOULD send a response version equal to the highest version 682 to which the server is conformant that has a major version less than 683 or equal to the one received in the request. A server MUST NOT send 684 a version to which it is not conformant. A server can send a 505 685 (HTTP Version Not Supported) response if it wishes, for any reason, 686 to refuse service of the client's major protocol version. 688 A server MAY send an HTTP/1.0 response to a request if it is known or 689 suspected that the client incorrectly implements the HTTP 690 specification and is incapable of correctly processing later version 691 responses, such as when a client fails to parse the version number 692 correctly or when an intermediary is known to blindly forward the 693 HTTP-version even when it doesn't conform to the given minor version 694 of the protocol. Such protocol downgrades SHOULD NOT be performed 695 unless triggered by specific client attributes, such as when one or 696 more of the request header fields (e.g., User-Agent) uniquely match 697 the values sent by a client known to be in error. 699 The intention of HTTP's versioning design is that the major number 700 will only be incremented if an incompatible message syntax is 701 introduced, and that the minor number will only be incremented when 702 changes made to the protocol have the effect of adding to the message 703 semantics or implying additional capabilities of the sender. 704 However, the minor version was not incremented for the changes 705 introduced between [RFC2068] and [RFC2616], and this revision has 706 specifically avoided any such changes to the protocol. 708 When an HTTP message is received with a major version number that the 709 recipient implements, but a higher minor version number than what the 710 recipient implements, the recipient SHOULD process the message as if 711 it were in the highest minor version within that major version to 712 which the recipient is conformant. A recipient can assume that a 713 message with a higher minor version, when sent to a recipient that 714 has not yet indicated support for that higher version, is 715 sufficiently backwards-compatible to be safely processed by any 716 implementation of the same major version. 718 2.7. Uniform Resource Identifiers 720 Uniform Resource Identifiers (URIs) [RFC3986] are used throughout 721 HTTP as the means for identifying resources (Section 2 of [SEMNTCS]). 722 URI references are used to target requests, indicate redirects, and 723 define relationships. 725 The definitions of "URI-reference", "absolute-URI", "relative-part", 726 "scheme", "authority", "port", "host", "path-abempty", "segment", 727 "query", and "fragment" are adopted from the URI generic syntax. An 728 "absolute-path" rule is defined for protocol elements that can 729 contain a non-empty path component. (This rule differs slightly from 730 the path-abempty rule of RFC 3986, which allows for an empty path to 731 be used in references, and path-absolute rule, which does not allow 732 paths that begin with "//".) A "partial-URI" rule is defined for 733 protocol elements that can contain a relative URI but not a fragment 734 component. 736 URI-reference = 737 absolute-URI = 738 relative-part = 739 scheme = 740 authority = 741 uri-host = 742 port = 743 path-abempty = 744 segment = 745 query = 746 fragment = 748 absolute-path = 1*( "/" segment ) 749 partial-URI = relative-part [ "?" query ] 751 Each protocol element in HTTP that allows a URI reference will 752 indicate in its ABNF production whether the element allows any form 753 of reference (URI-reference), only a URI in absolute form (absolute- 754 URI), only the path and optional query components, or some 755 combination of the above. Unless otherwise indicated, URI references 756 are parsed relative to the effective request URI (Section 5.5). 758 2.7.1. http URI Scheme 760 The "http" URI scheme is hereby defined for the purpose of minting 761 identifiers according to their association with the hierarchical 762 namespace governed by a potential HTTP origin server listening for 763 TCP ([RFC0793]) connections on a given port. 765 http-URI = "http:" "//" authority path-abempty [ "?" query ] 766 [ "#" fragment ] 768 The origin server for an "http" URI is identified by the authority 769 component, which includes a host identifier and optional TCP port 770 ([RFC3986], Section 3.2.2). The hierarchical path component and 771 optional query component serve as an identifier for a potential 772 target resource within that origin server's name space. The optional 773 fragment component allows for indirect identification of a secondary 774 resource, independent of the URI scheme, as defined in Section 3.5 of 775 [RFC3986]. 777 A sender MUST NOT generate an "http" URI with an empty host 778 identifier. A recipient that processes such a URI reference MUST 779 reject it as invalid. 781 If the host identifier is provided as an IP address, the origin 782 server is the listener (if any) on the indicated TCP port at that IP 783 address. If host is a registered name, the registered name is an 784 indirect identifier for use with a name resolution service, such as 785 DNS, to find an address for that origin server. If the port 786 subcomponent is empty or not given, TCP port 80 (the reserved port 787 for WWW services) is the default. 789 Note that the presence of a URI with a given authority component does 790 not imply that there is always an HTTP server listening for 791 connections on that host and port. Anyone can mint a URI. What the 792 authority component determines is who has the right to respond 793 authoritatively to requests that target the identified resource. The 794 delegated nature of registered names and IP addresses creates a 795 federated namespace, based on control over the indicated host and 796 port, whether or not an HTTP server is present. See Section 9.1 for 797 security considerations related to establishing authority. 799 When an "http" URI is used within a context that calls for access to 800 the indicated resource, a client MAY attempt access by resolving the 801 host to an IP address, establishing a TCP connection to that address 802 on the indicated port, and sending an HTTP request message 803 (Section 3) containing the URI's identifying data (Section 5) to the 804 server. If the server responds to that request with a non-interim 805 HTTP response message, as described in Section 6 of [SEMNTCS], then 806 that response is considered an authoritative answer to the client's 807 request. 809 Although HTTP is independent of the transport protocol, the "http" 810 scheme is specific to TCP-based services because the name delegation 811 process depends on TCP for establishing authority. An HTTP service 812 based on some other underlying connection protocol would presumably 813 be identified using a different URI scheme, just as the "https" 814 scheme (below) is used for resources that require an end-to-end 815 secured connection. Other protocols might also be used to provide 816 access to "http" identified resources -- it is only the authoritative 817 interface that is specific to TCP. 819 The URI generic syntax for authority also includes a deprecated 820 userinfo subcomponent ([RFC3986], Section 3.2.1) for including user 821 authentication information in the URI. Some implementations make use 822 of the userinfo component for internal configuration of 823 authentication information, such as within command invocation 824 options, configuration files, or bookmark lists, even though such 825 usage might expose a user identifier or password. A sender MUST NOT 826 generate the userinfo subcomponent (and its "@" delimiter) when an 827 "http" URI reference is generated within a message as a request 828 target or header field value. Before making use of an "http" URI 829 reference received from an untrusted source, a recipient SHOULD parse 830 for userinfo and treat its presence as an error; it is likely being 831 used to obscure the authority for the sake of phishing attacks. 833 2.7.2. https URI Scheme 835 The "https" URI scheme is hereby defined for the purpose of minting 836 identifiers according to their association with the hierarchical 837 namespace governed by a potential HTTP origin server listening to a 838 given TCP port for TLS-secured connections ([RFC5246]). 840 All of the requirements listed above for the "http" scheme are also 841 requirements for the "https" scheme, except that TCP port 443 is the 842 default if the port subcomponent is empty or not given, and the user 843 agent MUST ensure that its connection to the origin server is secured 844 through the use of strong encryption, end-to-end, prior to sending 845 the first HTTP request. 847 https-URI = "https:" "//" authority path-abempty [ "?" query ] 848 [ "#" fragment ] 850 Note that the "https" URI scheme depends on both TLS and TCP for 851 establishing authority. Resources made available via the "https" 852 scheme have no shared identity with the "http" scheme even if their 853 resource identifiers indicate the same authority (the same host 854 listening to the same TCP port). They are distinct namespaces and 855 are considered to be distinct origin servers. However, an extension 856 to HTTP that is defined to apply to entire host domains, such as the 857 Cookie protocol [RFC6265], can allow information set by one service 858 to impact communication with other services within a matching group 859 of host domains. 861 The process for authoritative access to an "https" identified 862 resource is defined in [RFC2818]. 864 2.7.3. http and https URI Normalization and Comparison 866 Since the "http" and "https" schemes conform to the URI generic 867 syntax, such URIs are normalized and compared according to the 868 algorithm defined in Section 6 of [RFC3986], using the defaults 869 described above for each scheme. 871 If the port is equal to the default port for a scheme, the normal 872 form is to omit the port subcomponent. When not being used in 873 absolute form as the request target of an OPTIONS request, an empty 874 path component is equivalent to an absolute path of "/", so the 875 normal form is to provide a path of "/" instead. The scheme and host 876 are case-insensitive and normally provided in lowercase; all other 877 components are compared in a case-sensitive manner. Characters other 878 than those in the "reserved" set are equivalent to their percent- 879 encoded octets: the normal form is to not encode them (see Sections 880 2.1 and 2.2 of [RFC3986]). 882 For example, the following three URIs are equivalent: 884 http://example.com:80/~smith/home.html 885 http://EXAMPLE.com/%7Esmith/home.html 886 http://EXAMPLE.com:/%7esmith/home.html 888 3. Message Format 890 All HTTP/1.1 messages consist of a start-line followed by a sequence 891 of octets in a format similar to the Internet Message Format 892 [RFC5322]: zero or more header fields (collectively referred to as 893 the "headers" or the "header section"), an empty line indicating the 894 end of the header section, and an optional message body. 896 HTTP-message = start-line 897 *( header-field CRLF ) 898 CRLF 899 [ message-body ] 901 The normal procedure for parsing an HTTP message is to read the 902 start-line into a structure, read each header field into a hash table 903 by field name until the empty line, and then use the parsed data to 904 determine if a message body is expected. If a message body has been 905 indicated, then it is read as a stream until an amount of octets 906 equal to the message body length is read or the connection is closed. 908 A recipient MUST parse an HTTP message as a sequence of octets in an 909 encoding that is a superset of US-ASCII [USASCII]. Parsing an HTTP 910 message as a stream of Unicode characters, without regard for the 911 specific encoding, creates security vulnerabilities due to the 912 varying ways that string processing libraries handle invalid 913 multibyte character sequences that contain the octet LF (%x0A). 914 String-based parsers can only be safely used within protocol elements 915 after the element has been extracted from the message, such as within 916 a header field-value after message parsing has delineated the 917 individual fields. 919 An HTTP message can be parsed as a stream for incremental processing 920 or forwarding downstream. However, recipients cannot rely on 921 incremental delivery of partial messages, since some implementations 922 will buffer or delay message forwarding for the sake of network 923 efficiency, security checks, or payload transformations. 925 A sender MUST NOT send whitespace between the start-line and the 926 first header field. A recipient that receives whitespace between the 927 start-line and the first header field MUST either reject the message 928 as invalid or consume each whitespace-preceded line without further 929 processing of it (i.e., ignore the entire line, along with any 930 subsequent lines preceded by whitespace, until a properly formed 931 header field is received or the header section is terminated). 933 The presence of such whitespace in a request might be an attempt to 934 trick a server into ignoring that field or processing the line after 935 it as a new request, either of which might result in a security 936 vulnerability if other implementations within the request chain 937 interpret the same message differently. Likewise, the presence of 938 such whitespace in a response might be ignored by some clients or 939 cause others to cease parsing. 941 3.1. Start Line 943 An HTTP message can be either a request from client to server or a 944 response from server to client. Syntactically, the two types of 945 message differ only in the start-line, which is either a request-line 946 (for requests) or a status-line (for responses), and in the algorithm 947 for determining the length of the message body (Section 3.3). 949 In theory, a client could receive requests and a server could receive 950 responses, distinguishing them by their different start-line formats, 951 but, in practice, servers are implemented to only expect a request (a 952 response is interpreted as an unknown or invalid request method) and 953 clients are implemented to only expect a response. 955 start-line = request-line / status-line 957 3.1.1. Request Line 959 A request-line begins with a method token, followed by a single space 960 (SP), the request-target, another single space (SP), the protocol 961 version, and ends with CRLF. 963 request-line = method SP request-target SP HTTP-version CRLF 965 The method token indicates the request method to be performed on the 966 target resource. The request method is case-sensitive. 968 method = token 970 The request methods defined by this specification can be found in 971 Section 4 of [SEMNTCS], along with information regarding the HTTP 972 method registry and considerations for defining new methods. 974 The request-target identifies the target resource upon which to apply 975 the request, as defined in Section 5.3. 977 Recipients typically parse the request-line into its component parts 978 by splitting on whitespace (see Section 3.5), since no whitespace is 979 allowed in the three components. Unfortunately, some user agents 980 fail to properly encode or exclude whitespace found in hypertext 981 references, resulting in those disallowed characters being sent in a 982 request-target. 984 Recipients of an invalid request-line SHOULD respond with either a 985 400 (Bad Request) error or a 301 (Moved Permanently) redirect with 986 the request-target properly encoded. A recipient SHOULD NOT attempt 987 to autocorrect and then process the request without a redirect, since 988 the invalid request-line might be deliberately crafted to bypass 989 security filters along the request chain. 991 HTTP does not place a predefined limit on the length of a request- 992 line, as described in Section 2.5. A server that receives a method 993 longer than any that it implements SHOULD respond with a 501 (Not 994 Implemented) status code. A server that receives a request-target 995 longer than any URI it wishes to parse MUST respond with a 414 (URI 996 Too Long) status code (see Section 6.5.12 of [SEMNTCS]). 998 Various ad hoc limitations on request-line length are found in 999 practice. It is RECOMMENDED that all HTTP senders and recipients 1000 support, at a minimum, request-line lengths of 8000 octets. 1002 3.1.2. Status Line 1004 The first line of a response message is the status-line, consisting 1005 of the protocol version, a space (SP), the status code, another 1006 space, a possibly empty textual phrase describing the status code, 1007 and ending with CRLF. 1009 status-line = HTTP-version SP status-code SP reason-phrase CRLF 1011 The status-code element is a 3-digit integer code describing the 1012 result of the server's attempt to understand and satisfy the client's 1013 corresponding request. The rest of the response message is to be 1014 interpreted in light of the semantics defined for that status code. 1015 See Section 6 of [SEMNTCS] for information about the semantics of 1016 status codes, including the classes of status code (indicated by the 1017 first digit), the status codes defined by this specification, 1018 considerations for the definition of new status codes, and the IANA 1019 registry. 1021 status-code = 3DIGIT 1023 The reason-phrase element exists for the sole purpose of providing a 1024 textual description associated with the numeric status code, mostly 1025 out of deference to earlier Internet application protocols that were 1026 more frequently used with interactive text clients. A client SHOULD 1027 ignore the reason-phrase content. 1029 reason-phrase = *( HTAB / SP / VCHAR / obs-text ) 1031 3.2. Header Fields 1033 Each header field consists of a case-insensitive field name followed 1034 by a colon (":"), optional leading whitespace, the field value, and 1035 optional trailing whitespace. 1037 header-field = field-name ":" OWS field-value OWS 1039 field-name = token 1040 field-value = *( field-content / obs-fold ) 1041 field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] 1042 field-vchar = VCHAR / obs-text 1044 obs-fold = CRLF 1*( SP / HTAB ) 1045 ; obsolete line folding 1046 ; see Section 3.2.4 1048 The field-name token labels the corresponding field-value as having 1049 the semantics defined by that header field. For example, the Date 1050 header field is defined in Section 7.1.1.2 of [SEMNTCS] as containing 1051 the origination timestamp for the message in which it appears. 1053 3.2.1. Field Extensibility 1055 Header fields are fully extensible: there is no limit on the 1056 introduction of new field names, each presumably defining new 1057 semantics, nor on the number of header fields used in a given 1058 message. Existing fields are defined in each part of this 1059 specification and in many other specifications outside this document 1060 set. 1062 New header fields can be defined such that, when they are understood 1063 by a recipient, they might override or enhance the interpretation of 1064 previously defined header fields, define preconditions on request 1065 evaluation, or refine the meaning of responses. 1067 A proxy MUST forward unrecognized header fields unless the field-name 1068 is listed in the Connection header field (Section 6.1) or the proxy 1069 is specifically configured to block, or otherwise transform, such 1070 fields. Other recipients SHOULD ignore unrecognized header fields. 1071 These requirements allow HTTP's functionality to be enhanced without 1072 requiring prior update of deployed intermediaries. 1074 All defined header fields ought to be registered with IANA in the 1075 "Message Headers" registry, as described in Section 8.3 of [SEMNTCS]. 1077 3.2.2. Field Order 1079 The order in which header fields with differing field names are 1080 received is not significant. However, it is good practice to send 1081 header fields that contain control data first, such as Host on 1082 requests and Date on responses, so that implementations can decide 1083 when not to handle a message as early as possible. A server MUST NOT 1084 apply a request to the target resource until the entire request 1085 header section is received, since later header fields might include 1086 conditionals, authentication credentials, or deliberately misleading 1087 duplicate header fields that would impact request processing. 1089 A sender MUST NOT generate multiple header fields with the same field 1090 name in a message unless either the entire field value for that 1091 header field is defined as a comma-separated list [i.e., #(values)] 1092 or the header field is a well-known exception (as noted below). 1094 A recipient MAY combine multiple header fields with the same field 1095 name into one "field-name: field-value" pair, without changing the 1096 semantics of the message, by appending each subsequent field value to 1097 the combined field value in order, separated by a comma. The order 1098 in which header fields with the same field name are received is 1099 therefore significant to the interpretation of the combined field 1100 value; a proxy MUST NOT change the order of these field values when 1101 forwarding a message. 1103 Note: In practice, the "Set-Cookie" header field ([RFC6265]) often 1104 appears multiple times in a response message and does not use the 1105 list syntax, violating the above requirements on multiple header 1106 fields with the same name. Since it cannot be combined into a 1107 single field-value, recipients ought to handle "Set-Cookie" as a 1108 special case while processing header fields. (See Appendix A.2.3 1109 of [Kri2001] for details.) 1111 3.2.3. Whitespace 1113 This specification uses three rules to denote the use of linear 1114 whitespace: OWS (optional whitespace), RWS (required whitespace), and 1115 BWS ("bad" whitespace). 1117 The OWS rule is used where zero or more linear whitespace octets 1118 might appear. For protocol elements where optional whitespace is 1119 preferred to improve readability, a sender SHOULD generate the 1120 optional whitespace as a single SP; otherwise, a sender SHOULD NOT 1121 generate optional whitespace except as needed to white out invalid or 1122 unwanted protocol elements during in-place message filtering. 1124 The RWS rule is used when at least one linear whitespace octet is 1125 required to separate field tokens. A sender SHOULD generate RWS as a 1126 single SP. 1128 The BWS rule is used where the grammar allows optional whitespace 1129 only for historical reasons. A sender MUST NOT generate BWS in 1130 messages. A recipient MUST parse for such bad whitespace and remove 1131 it before interpreting the protocol element. 1133 OWS = *( SP / HTAB ) 1134 ; optional whitespace 1135 RWS = 1*( SP / HTAB ) 1136 ; required whitespace 1137 BWS = OWS 1138 ; "bad" whitespace 1140 3.2.4. Field Parsing 1142 Messages are parsed using a generic algorithm, independent of the 1143 individual header field names. The contents within a given field 1144 value are not parsed until a later stage of message interpretation 1145 (usually after the message's entire header section has been 1146 processed). Consequently, this specification does not use ABNF rules 1147 to define each "Field-Name: Field Value" pair, as was done in 1148 previous editions. Instead, this specification uses ABNF rules that 1149 are named according to each registered field name, wherein the rule 1150 defines the valid grammar for that field's corresponding field values 1151 (i.e., after the field-value has been extracted from the header 1152 section by a generic field parser). 1154 No whitespace is allowed between the header field-name and colon. In 1155 the past, differences in the handling of such whitespace have led to 1156 security vulnerabilities in request routing and response handling. A 1157 server MUST reject any received request message that contains 1158 whitespace between a header field-name and colon with a response code 1159 of 400 (Bad Request). A proxy MUST remove any such whitespace from a 1160 response message before forwarding the message downstream. 1162 A field value might be preceded and/or followed by optional 1163 whitespace (OWS); a single SP preceding the field-value is preferred 1164 for consistent readability by humans. The field value does not 1165 include any leading or trailing whitespace: OWS occurring before the 1166 first non-whitespace octet of the field value or after the last non- 1167 whitespace octet of the field value ought to be excluded by parsers 1168 when extracting the field value from a header field. 1170 Historically, HTTP header field values could be extended over 1171 multiple lines by preceding each extra line with at least one space 1172 or horizontal tab (obs-fold). This specification deprecates such 1173 line folding except within the message/http media type 1174 (Section 8.3.1). A sender MUST NOT generate a message that includes 1175 line folding (i.e., that has any field-value that contains a match to 1176 the obs-fold rule) unless the message is intended for packaging 1177 within the message/http media type. 1179 A server that receives an obs-fold in a request message that is not 1180 within a message/http container MUST either reject the message by 1181 sending a 400 (Bad Request), preferably with a representation 1182 explaining that obsolete line folding is unacceptable, or replace 1183 each received obs-fold with one or more SP octets prior to 1184 interpreting the field value or forwarding the message downstream. 1186 A proxy or gateway that receives an obs-fold in a response message 1187 that is not within a message/http container MUST either discard the 1188 message and replace it with a 502 (Bad Gateway) response, preferably 1189 with a representation explaining that unacceptable line folding was 1190 received, or replace each received obs-fold with one or more SP 1191 octets prior to interpreting the field value or forwarding the 1192 message downstream. 1194 A user agent that receives an obs-fold in a response message that is 1195 not within a message/http container MUST replace each received obs- 1196 fold with one or more SP octets prior to interpreting the field 1197 value. 1199 Historically, HTTP has allowed field content with text in the 1200 ISO-8859-1 charset [ISO-8859-1], supporting other charsets only 1201 through use of [RFC2047] encoding. In practice, most HTTP header 1202 field values use only a subset of the US-ASCII charset [USASCII]. 1203 Newly defined header fields SHOULD limit their field values to 1204 US-ASCII octets. A recipient SHOULD treat other octets in field 1205 content (obs-text) as opaque data. 1207 3.2.5. Field Limits 1209 HTTP does not place a predefined limit on the length of each header 1210 field or on the length of the header section as a whole, as described 1211 in Section 2.5. Various ad hoc limitations on individual header 1212 field length are found in practice, often depending on the specific 1213 field semantics. 1215 A server that receives a request header field, or set of fields, 1216 larger than it wishes to process MUST respond with an appropriate 4xx 1217 (Client Error) status code. Ignoring such header fields would 1218 increase the server's vulnerability to request smuggling attacks 1219 (Section 9.5). 1221 A client MAY discard or truncate received header fields that are 1222 larger than the client wishes to process if the field semantics are 1223 such that the dropped value(s) can be safely ignored without changing 1224 the message framing or response semantics. 1226 3.2.6. Field Value Components 1228 Most HTTP header field values are defined using common syntax 1229 components (token, quoted-string, and comment) separated by 1230 whitespace or specific delimiting characters. Delimiters are chosen 1231 from the set of US-ASCII visual characters not allowed in a token 1232 (DQUOTE and "(),/:;<=>?@[\]{}"). 1234 token = 1*tchar 1236 tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" 1237 / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" 1238 / DIGIT / ALPHA 1239 ; any VCHAR, except delimiters 1241 A string of text is parsed as a single value if it is quoted using 1242 double-quote marks. 1244 quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE 1245 qdtext = HTAB / SP /%x21 / %x23-5B / %x5D-7E / obs-text 1246 obs-text = %x80-FF 1248 Comments can be included in some HTTP header fields by surrounding 1249 the comment text with parentheses. Comments are only allowed in 1250 fields containing "comment" as part of their field value definition. 1252 comment = "(" *( ctext / quoted-pair / comment ) ")" 1253 ctext = HTAB / SP / %x21-27 / %x2A-5B / %x5D-7E / obs-text 1255 The backslash octet ("\") can be used as a single-octet quoting 1256 mechanism within quoted-string and comment constructs. Recipients 1257 that process the value of a quoted-string MUST handle a quoted-pair 1258 as if it were replaced by the octet following the backslash. 1260 quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) 1262 A sender SHOULD NOT generate a quoted-pair in a quoted-string except 1263 where necessary to quote DQUOTE and backslash octets occurring within 1264 that string. A sender SHOULD NOT generate a quoted-pair in a comment 1265 except where necessary to quote parentheses ["(" and ")"] and 1266 backslash octets occurring within that comment. 1268 3.3. Message Body 1270 The message body (if any) of an HTTP message is used to carry the 1271 payload body of that request or response. The message body is 1272 identical to the payload body unless a transfer coding has been 1273 applied, as described in Section 3.3.1. 1275 message-body = *OCTET 1277 The rules for when a message body is allowed in a message differ for 1278 requests and responses. 1280 The presence of a message body in a request is signaled by a Content- 1281 Length or Transfer-Encoding header field. Request message framing is 1282 independent of method semantics, even if the method does not define 1283 any use for a message body. 1285 The presence of a message body in a response depends on both the 1286 request method to which it is responding and the response status code 1287 (Section 3.1.2). Responses to the HEAD request method (Section 4.3.2 1288 of [SEMNTCS]) never include a message body because the associated 1289 response header fields (e.g., Transfer-Encoding, Content-Length, 1290 etc.), if present, indicate only what their values would have been if 1291 the request method had been GET (Section 4.3.1 of [SEMNTCS]). 2xx 1292 (Successful) responses to a CONNECT request method (Section 4.3.6 of 1293 [SEMNTCS]) switch to tunnel mode instead of having a message body. 1294 All 1xx (Informational), 204 (No Content), and 304 (Not Modified) 1295 responses do not include a message body. All other responses do 1296 include a message body, although the body might be of zero length. 1298 3.3.1. Transfer-Encoding 1300 The Transfer-Encoding header field lists the transfer coding names 1301 corresponding to the sequence of transfer codings that have been (or 1302 will be) applied to the payload body in order to form the message 1303 body. Transfer codings are defined in Section 4. 1305 Transfer-Encoding = 1#transfer-coding 1307 Transfer-Encoding is analogous to the Content-Transfer-Encoding field 1308 of MIME, which was designed to enable safe transport of binary data 1309 over a 7-bit transport service ([RFC2045], Section 6). However, safe 1310 transport has a different focus for an 8bit-clean transfer protocol. 1311 In HTTP's case, Transfer-Encoding is primarily intended to accurately 1312 delimit a dynamically generated payload and to distinguish payload 1313 encodings that are only applied for transport efficiency or security 1314 from those that are characteristics of the selected resource. 1316 A recipient MUST be able to parse the chunked transfer coding 1317 (Section 4.1) because it plays a crucial role in framing messages 1318 when the payload body size is not known in advance. A sender MUST 1319 NOT apply chunked more than once to a message body (i.e., chunking an 1320 already chunked message is not allowed). If any transfer coding 1321 other than chunked is applied to a request payload body, the sender 1322 MUST apply chunked as the final transfer coding to ensure that the 1323 message is properly framed. If any transfer coding other than 1324 chunked is applied to a response payload body, the sender MUST either 1325 apply chunked as the final transfer coding or terminate the message 1326 by closing the connection. 1328 For example, 1330 Transfer-Encoding: gzip, chunked 1332 indicates that the payload body has been compressed using the gzip 1333 coding and then chunked using the chunked coding while forming the 1334 message body. 1336 Unlike Content-Encoding (Section 3.1.2.1 of [SEMNTCS]), Transfer- 1337 Encoding is a property of the message, not of the representation, and 1338 any recipient along the request/response chain MAY decode the 1339 received transfer coding(s) or apply additional transfer coding(s) to 1340 the message body, assuming that corresponding changes are made to the 1341 Transfer-Encoding field-value. Additional information about the 1342 encoding parameters can be provided by other header fields not 1343 defined by this specification. 1345 Transfer-Encoding MAY be sent in a response to a HEAD request or in a 1346 304 (Not Modified) response (Section 4.1 of [CONDTNL]) to a GET 1347 request, neither of which includes a message body, to indicate that 1348 the origin server would have applied a transfer coding to the message 1349 body if the request had been an unconditional GET. This indication 1350 is not required, however, because any recipient on the response chain 1351 (including the origin server) can remove transfer codings when they 1352 are not needed. 1354 A server MUST NOT send a Transfer-Encoding header field in any 1355 response with a status code of 1xx (Informational) or 204 (No 1356 Content). A server MUST NOT send a Transfer-Encoding header field in 1357 any 2xx (Successful) response to a CONNECT request (Section 4.3.6 of 1358 [SEMNTCS]). 1360 Transfer-Encoding was added in HTTP/1.1. It is generally assumed 1361 that implementations advertising only HTTP/1.0 support will not 1362 understand how to process a transfer-encoded payload. A client MUST 1363 NOT send a request containing Transfer-Encoding unless it knows the 1364 server will handle HTTP/1.1 (or later) requests; such knowledge might 1365 be in the form of specific user configuration or by remembering the 1366 version of a prior received response. A server MUST NOT send a 1367 response containing Transfer-Encoding unless the corresponding 1368 request indicates HTTP/1.1 (or later). 1370 A server that receives a request message with a transfer coding it 1371 does not understand SHOULD respond with 501 (Not Implemented). 1373 3.3.2. Content-Length 1375 When a message does not have a Transfer-Encoding header field, a 1376 Content-Length header field can provide the anticipated size, as a 1377 decimal number of octets, for a potential payload body. For messages 1378 that do include a payload body, the Content-Length field-value 1379 provides the framing information necessary for determining where the 1380 body (and message) ends. For messages that do not include a payload 1381 body, the Content-Length indicates the size of the selected 1382 representation (Section 3 of [SEMNTCS]). 1384 Content-Length = 1*DIGIT 1386 An example is 1388 Content-Length: 3495 1390 A sender MUST NOT send a Content-Length header field in any message 1391 that contains a Transfer-Encoding header field. 1393 A user agent SHOULD send a Content-Length in a request message when 1394 no Transfer-Encoding is sent and the request method defines a meaning 1395 for an enclosed payload body. For example, a Content-Length header 1396 field is normally sent in a POST request even when the value is 0 1397 (indicating an empty payload body). A user agent SHOULD NOT send a 1398 Content-Length header field when the request message does not contain 1399 a payload body and the method semantics do not anticipate such a 1400 body. 1402 A server MAY send a Content-Length header field in a response to a 1403 HEAD request (Section 4.3.2 of [SEMNTCS]); a server MUST NOT send 1404 Content-Length in such a response unless its field-value equals the 1405 decimal number of octets that would have been sent in the payload 1406 body of a response if the same request had used the GET method. 1408 A server MAY send a Content-Length header field in a 304 (Not 1409 Modified) response to a conditional GET request (Section 4.1 of 1410 [CONDTNL]); a server MUST NOT send Content-Length in such a response 1411 unless its field-value equals the decimal number of octets that would 1412 have been sent in the payload body of a 200 (OK) response to the same 1413 request. 1415 A server MUST NOT send a Content-Length header field in any response 1416 with a status code of 1xx (Informational) or 204 (No Content). A 1417 server MUST NOT send a Content-Length header field in any 2xx 1418 (Successful) response to a CONNECT request (Section 4.3.6 of 1419 [SEMNTCS]). 1421 Aside from the cases defined above, in the absence of Transfer- 1422 Encoding, an origin server SHOULD send a Content-Length header field 1423 when the payload body size is known prior to sending the complete 1424 header section. This will allow downstream recipients to measure 1425 transfer progress, know when a received message is complete, and 1426 potentially reuse the connection for additional requests. 1428 Any Content-Length field value greater than or equal to zero is 1429 valid. Since there is no predefined limit to the length of a 1430 payload, a recipient MUST anticipate potentially large decimal 1431 numerals and prevent parsing errors due to integer conversion 1432 overflows (Section 9.3). 1434 If a message is received that has multiple Content-Length header 1435 fields with field-values consisting of the same decimal value, or a 1436 single Content-Length header field with a field value containing a 1437 list of identical decimal values (e.g., "Content-Length: 42, 42"), 1438 indicating that duplicate Content-Length header fields have been 1439 generated or combined by an upstream message processor, then the 1440 recipient MUST either reject the message as invalid or replace the 1441 duplicated field-values with a single valid Content-Length field 1442 containing that decimal value prior to determining the message body 1443 length or forwarding the message. 1445 Note: HTTP's use of Content-Length for message framing differs 1446 significantly from the same field's use in MIME, where it is an 1447 optional field used only within the "message/external-body" media- 1448 type. 1450 3.3.3. Message Body Length 1452 The length of a message body is determined by one of the following 1453 (in order of precedence): 1455 1. Any response to a HEAD request and any response with a 1xx 1456 (Informational), 204 (No Content), or 304 (Not Modified) status 1457 code is always terminated by the first empty line after the 1458 header fields, regardless of the header fields present in the 1459 message, and thus cannot contain a message body. 1461 2. Any 2xx (Successful) response to a CONNECT request implies that 1462 the connection will become a tunnel immediately after the empty 1463 line that concludes the header fields. A client MUST ignore any 1464 Content-Length or Transfer-Encoding header fields received in 1465 such a message. 1467 3. If a Transfer-Encoding header field is present and the chunked 1468 transfer coding (Section 4.1) is the final encoding, the message 1469 body length is determined by reading and decoding the chunked 1470 data until the transfer coding indicates the data is complete. 1472 If a Transfer-Encoding header field is present in a response and 1473 the chunked transfer coding is not the final encoding, the 1474 message body length is determined by reading the connection until 1475 it is closed by the server. If a Transfer-Encoding header field 1476 is present in a request and the chunked transfer coding is not 1477 the final encoding, the message body length cannot be determined 1478 reliably; the server MUST respond with the 400 (Bad Request) 1479 status code and then close the connection. 1481 If a message is received with both a Transfer-Encoding and a 1482 Content-Length header field, the Transfer-Encoding overrides the 1483 Content-Length. Such a message might indicate an attempt to 1484 perform request smuggling (Section 9.5) or response splitting 1485 (Section 9.4) and ought to be handled as an error. A sender MUST 1486 remove the received Content-Length field prior to forwarding such 1487 a message downstream. 1489 4. If a message is received without Transfer-Encoding and with 1490 either multiple Content-Length header fields having differing 1491 field-values or a single Content-Length header field having an 1492 invalid value, then the message framing is invalid and the 1493 recipient MUST treat it as an unrecoverable error. If this is a 1494 request message, the server MUST respond with a 400 (Bad Request) 1495 status code and then close the connection. If this is a response 1496 message received by a proxy, the proxy MUST close the connection 1497 to the server, discard the received response, and send a 502 (Bad 1498 Gateway) response to the client. If this is a response message 1499 received by a user agent, the user agent MUST close the 1500 connection to the server and discard the received response. 1502 5. If a valid Content-Length header field is present without 1503 Transfer-Encoding, its decimal value defines the expected message 1504 body length in octets. If the sender closes the connection or 1505 the recipient times out before the indicated number of octets are 1506 received, the recipient MUST consider the message to be 1507 incomplete and close the connection. 1509 6. If this is a request message and none of the above are true, then 1510 the message body length is zero (no message body is present). 1512 7. Otherwise, this is a response message without a declared message 1513 body length, so the message body length is determined by the 1514 number of octets received prior to the server closing the 1515 connection. 1517 Since there is no way to distinguish a successfully completed, close- 1518 delimited message from a partially received message interrupted by 1519 network failure, a server SHOULD generate encoding or length- 1520 delimited messages whenever possible. The close-delimiting feature 1521 exists primarily for backwards compatibility with HTTP/1.0. 1523 A server MAY reject a request that contains a message body but not a 1524 Content-Length by responding with 411 (Length Required). 1526 Unless a transfer coding other than chunked has been applied, a 1527 client that sends a request containing a message body SHOULD use a 1528 valid Content-Length header field if the message body length is known 1529 in advance, rather than the chunked transfer coding, since some 1530 existing services respond to chunked with a 411 (Length Required) 1531 status code even though they understand the chunked transfer coding. 1532 This is typically because such services are implemented via a gateway 1533 that requires a content-length in advance of being called and the 1534 server is unable or unwilling to buffer the entire request before 1535 processing. 1537 A user agent that sends a request containing a message body MUST send 1538 a valid Content-Length header field if it does not know the server 1539 will handle HTTP/1.1 (or later) requests; such knowledge can be in 1540 the form of specific user configuration or by remembering the version 1541 of a prior received response. 1543 If the final response to the last request on a connection has been 1544 completely received and there remains additional data to read, a user 1545 agent MAY discard the remaining data or attempt to determine if that 1546 data belongs as part of the prior response body, which might be the 1547 case if the prior message's Content-Length value is incorrect. A 1548 client MUST NOT process, cache, or forward such extra data as a 1549 separate response, since such behavior would be vulnerable to cache 1550 poisoning. 1552 3.4. Handling Incomplete Messages 1554 A server that receives an incomplete request message, usually due to 1555 a canceled request or a triggered timeout exception, MAY send an 1556 error response prior to closing the connection. 1558 A client that receives an incomplete response message, which can 1559 occur when a connection is closed prematurely or when decoding a 1560 supposedly chunked transfer coding fails, MUST record the message as 1561 incomplete. Cache requirements for incomplete responses are defined 1562 in Section 3 of [CACHING]. 1564 If a response terminates in the middle of the header section (before 1565 the empty line is received) and the status code might rely on header 1566 fields to convey the full meaning of the response, then the client 1567 cannot assume that meaning has been conveyed; the client might need 1568 to repeat the request in order to determine what action to take next. 1570 A message body that uses the chunked transfer coding is incomplete if 1571 the zero-sized chunk that terminates the encoding has not been 1572 received. A message that uses a valid Content-Length is incomplete 1573 if the size of the message body received (in octets) is less than the 1574 value given by Content-Length. A response that has neither chunked 1575 transfer coding nor Content-Length is terminated by closure of the 1576 connection and, thus, is considered complete regardless of the number 1577 of message body octets received, provided that the header section was 1578 received intact. 1580 3.5. Message Parsing Robustness 1582 Older HTTP/1.0 user agent implementations might send an extra CRLF 1583 after a POST request as a workaround for some early server 1584 applications that failed to read message body content that was not 1585 terminated by a line-ending. An HTTP/1.1 user agent MUST NOT preface 1586 or follow a request with an extra CRLF. If terminating the request 1587 message body with a line-ending is desired, then the user agent MUST 1588 count the terminating CRLF octets as part of the message body length. 1590 In the interest of robustness, a server that is expecting to receive 1591 and parse a request-line SHOULD ignore at least one empty line (CRLF) 1592 received prior to the request-line. 1594 Although the line terminator for the start-line and header fields is 1595 the sequence CRLF, a recipient MAY recognize a single LF as a line 1596 terminator and ignore any preceding CR. 1598 Although the request-line and status-line grammar rules require that 1599 each of the component elements be separated by a single SP octet, 1600 recipients MAY instead parse on whitespace-delimited word boundaries 1601 and, aside from the CRLF terminator, treat any form of whitespace as 1602 the SP separator while ignoring preceding or trailing whitespace; 1603 such whitespace includes one or more of the following octets: SP, 1604 HTAB, VT (%x0B), FF (%x0C), or bare CR. However, lenient parsing can 1605 result in security vulnerabilities if there are multiple recipients 1606 of the message and each has its own unique interpretation of 1607 robustness (see Section 9.5). 1609 When a server listening only for HTTP request messages, or processing 1610 what appears from the start-line to be an HTTP request message, 1611 receives a sequence of octets that does not match the HTTP-message 1612 grammar aside from the robustness exceptions listed above, the server 1613 SHOULD respond with a 400 (Bad Request) response. 1615 4. Transfer Codings 1617 Transfer coding names are used to indicate an encoding transformation 1618 that has been, can be, or might need to be applied to a payload body 1619 in order to ensure "safe transport" through the network. This 1620 differs from a content coding in that the transfer coding is a 1621 property of the message rather than a property of the representation 1622 that is being transferred. 1624 transfer-coding = "chunked" ; Section 4.1 1625 / "compress" ; Section 4.2.1 1626 / "deflate" ; Section 4.2.2 1627 / "gzip" ; Section 4.2.3 1628 / transfer-extension 1629 transfer-extension = token *( OWS ";" OWS transfer-parameter ) 1631 Parameters are in the form of a name or name=value pair. 1633 transfer-parameter = token BWS "=" BWS ( token / quoted-string ) 1635 All transfer-coding names are case-insensitive and ought to be 1636 registered within the HTTP Transfer Coding registry, as defined in 1637 Section 8.4. They are used in the TE (Section 4.3) and Transfer- 1638 Encoding (Section 3.3.1) header fields. 1640 4.1. Chunked Transfer Coding 1642 The chunked transfer coding wraps the payload body in order to 1643 transfer it as a series of chunks, each with its own size indicator, 1644 followed by an OPTIONAL trailer containing header fields. Chunked 1645 enables content streams of unknown size to be transferred as a 1646 sequence of length-delimited buffers, which enables the sender to 1647 retain connection persistence and the recipient to know when it has 1648 received the entire message. 1650 chunked-body = *chunk 1651 last-chunk 1652 trailer-part 1653 CRLF 1655 chunk = chunk-size [ chunk-ext ] CRLF 1656 chunk-data CRLF 1657 chunk-size = 1*HEXDIG 1658 last-chunk = 1*("0") [ chunk-ext ] CRLF 1660 chunk-data = 1*OCTET ; a sequence of chunk-size octets 1662 The chunk-size field is a string of hex digits indicating the size of 1663 the chunk-data in octets. The chunked transfer coding is complete 1664 when a chunk with a chunk-size of zero is received, possibly followed 1665 by a trailer, and finally terminated by an empty line. 1667 A recipient MUST be able to parse and decode the chunked transfer 1668 coding. 1670 4.1.1. Chunk Extensions 1672 The chunked encoding allows each chunk to include zero or more chunk 1673 extensions, immediately following the chunk-size, for the sake of 1674 supplying per-chunk metadata (such as a signature or hash), mid- 1675 message control information, or randomization of message body size. 1677 chunk-ext = *( ";" chunk-ext-name [ "=" chunk-ext-val ] ) 1679 chunk-ext-name = token 1680 chunk-ext-val = token / quoted-string 1682 The chunked encoding is specific to each connection and is likely to 1683 be removed or recoded by each recipient (including intermediaries) 1684 before any higher-level application would have a chance to inspect 1685 the extensions. Hence, use of chunk extensions is generally limited 1686 to specialized HTTP services such as "long polling" (where client and 1687 server can have shared expectations regarding the use of chunk 1688 extensions) or for padding within an end-to-end secured connection. 1690 A recipient MUST ignore unrecognized chunk extensions. A server 1691 ought to limit the total length of chunk extensions received in a 1692 request to an amount reasonable for the services provided, in the 1693 same way that it applies length limitations and timeouts for other 1694 parts of a message, and generate an appropriate 4xx (Client Error) 1695 response if that amount is exceeded. 1697 4.1.2. Chunked Trailer Part 1699 A trailer allows the sender to include additional fields at the end 1700 of a chunked message in order to supply metadata that might be 1701 dynamically generated while the message body is sent, such as a 1702 message integrity check, digital signature, or post-processing 1703 status. The trailer fields are identical to header fields, except 1704 they are sent in a chunked trailer instead of the message's header 1705 section. 1707 trailer-part = *( header-field CRLF ) 1709 A sender MUST NOT generate a trailer that contains a field necessary 1710 for message framing (e.g., Transfer-Encoding and Content-Length), 1711 routing (e.g., Host), request modifiers (e.g., controls and 1712 conditionals in Section 5 of [SEMNTCS]), authentication (e.g., see 1713 [AUTHFRM] and [RFC6265]), response control data (e.g., see 1714 Section 7.1 of [SEMNTCS]), or determining how to process the payload 1715 (e.g., Content-Encoding, Content-Type, Content-Range, and Trailer). 1717 When a chunked message containing a non-empty trailer is received, 1718 the recipient MAY process the fields (aside from those forbidden 1719 above) as if they were appended to the message's header section. A 1720 recipient MUST ignore (or consider as an error) any fields that are 1721 forbidden to be sent in a trailer, since processing them as if they 1722 were present in the header section might bypass external security 1723 filters. 1725 Unless the request includes a TE header field indicating "trailers" 1726 is acceptable, as described in Section 4.3, a server SHOULD NOT 1727 generate trailer fields that it believes are necessary for the user 1728 agent to receive. Without a TE containing "trailers", the server 1729 ought to assume that the trailer fields might be silently discarded 1730 along the path to the user agent. This requirement allows 1731 intermediaries to forward a de-chunked message to an HTTP/1.0 1732 recipient without buffering the entire response. 1734 4.1.3. Decoding Chunked 1736 A process for decoding the chunked transfer coding can be represented 1737 in pseudo-code as: 1739 length := 0 1740 read chunk-size, chunk-ext (if any), and CRLF 1741 while (chunk-size > 0) { 1742 read chunk-data and CRLF 1743 append chunk-data to decoded-body 1744 length := length + chunk-size 1745 read chunk-size, chunk-ext (if any), and CRLF 1746 } 1747 read trailer field 1748 while (trailer field is not empty) { 1749 if (trailer field is allowed to be sent in a trailer) { 1750 append trailer field to existing header fields 1751 } 1752 read trailer-field 1753 } 1754 Content-Length := length 1755 Remove "chunked" from Transfer-Encoding 1756 Remove Trailer from existing header fields 1758 4.2. Compression Codings 1760 The codings defined below can be used to compress the payload of a 1761 message. 1763 4.2.1. Compress Coding 1765 The "compress" coding is an adaptive Lempel-Ziv-Welch (LZW) coding 1766 [Welch] that is commonly produced by the UNIX file compression 1767 program "compress". A recipient SHOULD consider "x-compress" to be 1768 equivalent to "compress". 1770 4.2.2. Deflate Coding 1772 The "deflate" coding is a "zlib" data format [RFC1950] containing a 1773 "deflate" compressed data stream [RFC1951] that uses a combination of 1774 the Lempel-Ziv (LZ77) compression algorithm and Huffman coding. 1776 Note: Some non-conformant implementations send the "deflate" 1777 compressed data without the zlib wrapper. 1779 4.2.3. Gzip Coding 1781 The "gzip" coding is an LZ77 coding with a 32-bit Cyclic Redundancy 1782 Check (CRC) that is commonly produced by the gzip file compression 1783 program [RFC1952]. A recipient SHOULD consider "x-gzip" to be 1784 equivalent to "gzip". 1786 4.3. TE 1788 The "TE" header field in a request indicates what transfer codings, 1789 besides chunked, the client is willing to accept in response, and 1790 whether or not the client is willing to accept trailer fields in a 1791 chunked transfer coding. 1793 The TE field-value consists of a comma-separated list of transfer 1794 coding names, each allowing for optional parameters (as described in 1795 Section 4), and/or the keyword "trailers". A client MUST NOT send 1796 the chunked transfer coding name in TE; chunked is always acceptable 1797 for HTTP/1.1 recipients. 1799 TE = #t-codings 1800 t-codings = "trailers" / ( transfer-coding [ t-ranking ] ) 1801 t-ranking = OWS ";" OWS "q=" rank 1802 rank = ( "0" [ "." 0*3DIGIT ] ) 1803 / ( "1" [ "." 0*3("0") ] ) 1805 Three examples of TE use are below. 1807 TE: deflate 1808 TE: 1809 TE: trailers, deflate;q=0.5 1811 The presence of the keyword "trailers" indicates that the client is 1812 willing to accept trailer fields in a chunked transfer coding, as 1813 defined in Section 4.1.2, on behalf of itself and any downstream 1814 clients. For requests from an intermediary, this implies that 1815 either: (a) all downstream clients are willing to accept trailer 1816 fields in the forwarded response; or, (b) the intermediary will 1817 attempt to buffer the response on behalf of downstream recipients. 1818 Note that HTTP/1.1 does not define any means to limit the size of a 1819 chunked response such that an intermediary can be assured of 1820 buffering the entire response. 1822 When multiple transfer codings are acceptable, the client MAY rank 1823 the codings by preference using a case-insensitive "q" parameter 1824 (similar to the qvalues used in content negotiation fields, 1825 Section 5.3.1 of [SEMNTCS]). The rank value is a real number in the 1826 range 0 through 1, where 0.001 is the least preferred and 1 is the 1827 most preferred; a value of 0 means "not acceptable". 1829 If the TE field-value is empty or if no TE field is present, the only 1830 acceptable transfer coding is chunked. A message with no transfer 1831 coding is always acceptable. 1833 Since the TE header field only applies to the immediate connection, a 1834 sender of TE MUST also send a "TE" connection option within the 1835 Connection header field (Section 6.1) in order to prevent the TE 1836 field from being forwarded by intermediaries that do not support its 1837 semantics. 1839 4.4. Trailer 1841 When a message includes a message body encoded with the chunked 1842 transfer coding and the sender desires to send metadata in the form 1843 of trailer fields at the end of the message, the sender SHOULD 1844 generate a Trailer header field before the message body to indicate 1845 which fields will be present in the trailers. This allows the 1846 recipient to prepare for receipt of that metadata before it starts 1847 processing the body, which is useful if the message is being streamed 1848 and the recipient wishes to confirm an integrity check on the fly. 1850 Trailer = 1#field-name 1852 5. Message Routing 1854 HTTP request message routing is determined by each client based on 1855 the target resource, the client's proxy configuration, and 1856 establishment or reuse of an inbound connection. The corresponding 1857 response routing follows the same connection chain back to the 1858 client. 1860 5.1. Identifying a Target Resource 1862 HTTP is used in a wide variety of applications, ranging from general- 1863 purpose computers to home appliances. In some cases, communication 1864 options are hard-coded in a client's configuration. However, most 1865 HTTP clients rely on the same resource identification mechanism and 1866 configuration techniques as general-purpose Web browsers. 1868 HTTP communication is initiated by a user agent for some purpose. 1869 The purpose is a combination of request semantics, which are defined 1870 in [SEMNTCS], and a target resource upon which to apply those 1871 semantics. A URI reference (Section 2.7) is typically used as an 1872 identifier for the "target resource", which a user agent would 1873 resolve to its absolute form in order to obtain the "target URI". 1874 The target URI excludes the reference's fragment component, if any, 1875 since fragment identifiers are reserved for client-side processing 1876 ([RFC3986], Section 3.5). 1878 5.2. Connecting Inbound 1880 Once the target URI is determined, a client needs to decide whether a 1881 network request is necessary to accomplish the desired semantics and, 1882 if so, where that request is to be directed. 1884 If the client has a cache [CACHING] and the request can be satisfied 1885 by it, then the request is usually directed there first. 1887 If the request is not satisfied by a cache, then a typical client 1888 will check its configuration to determine whether a proxy is to be 1889 used to satisfy the request. Proxy configuration is implementation- 1890 dependent, but is often based on URI prefix matching, selective 1891 authority matching, or both, and the proxy itself is usually 1892 identified by an "http" or "https" URI. If a proxy is applicable, 1893 the client connects inbound by establishing (or reusing) a connection 1894 to that proxy. 1896 If no proxy is applicable, a typical client will invoke a handler 1897 routine, usually specific to the target URI's scheme, to connect 1898 directly to an authority for the target resource. How that is 1899 accomplished is dependent on the target URI scheme and defined by its 1900 associated specification, similar to how this specification defines 1901 origin server access for resolution of the "http" (Section 2.7.1) and 1902 "https" (Section 2.7.2) schemes. 1904 HTTP requirements regarding connection management are defined in 1905 Section 6. 1907 5.3. Request Target 1909 Once an inbound connection is obtained, the client sends an HTTP 1910 request message (Section 3) with a request-target derived from the 1911 target URI. There are four distinct formats for the request-target, 1912 depending on both the method being requested and whether the request 1913 is to a proxy. 1915 request-target = origin-form 1916 / absolute-form 1917 / authority-form 1918 / asterisk-form 1920 5.3.1. origin-form 1922 The most common form of request-target is the origin-form. 1924 origin-form = absolute-path [ "?" query ] 1926 When making a request directly to an origin server, other than a 1927 CONNECT or server-wide OPTIONS request (as detailed below), a client 1928 MUST send only the absolute path and query components of the target 1929 URI as the request-target. If the target URI's path component is 1930 empty, the client MUST send "/" as the path within the origin-form of 1931 request-target. A Host header field is also sent, as defined in 1932 Section 5.4. 1934 For example, a client wishing to retrieve a representation of the 1935 resource identified as 1937 http://www.example.org/where?q=now 1939 directly from the origin server would open (or reuse) a TCP 1940 connection to port 80 of the host "www.example.org" and send the 1941 lines: 1943 GET /where?q=now HTTP/1.1 1944 Host: www.example.org 1946 followed by the remainder of the request message. 1948 5.3.2. absolute-form 1950 When making a request to a proxy, other than a CONNECT or server-wide 1951 OPTIONS request (as detailed below), a client MUST send the target 1952 URI in absolute-form as the request-target. 1954 absolute-form = absolute-URI 1956 The proxy is requested to either service that request from a valid 1957 cache, if possible, or make the same request on the client's behalf 1958 to either the next inbound proxy server or directly to the origin 1959 server indicated by the request-target. Requirements on such 1960 "forwarding" of messages are defined in Section 5.7. 1962 An example absolute-form of request-line would be: 1964 GET http://www.example.org/pub/WWW/TheProject.html HTTP/1.1 1966 To allow for transition to the absolute-form for all requests in some 1967 future version of HTTP, a server MUST accept the absolute-form in 1968 requests, even though HTTP/1.1 clients will only send them in 1969 requests to proxies. 1971 5.3.3. authority-form 1973 The authority-form of request-target is only used for CONNECT 1974 requests (Section 4.3.6 of [SEMNTCS]). 1976 authority-form = authority 1978 When making a CONNECT request to establish a tunnel through one or 1979 more proxies, a client MUST send only the target URI's authority 1980 component (excluding any userinfo and its "@" delimiter) as the 1981 request-target. For example, 1983 CONNECT www.example.com:80 HTTP/1.1 1985 5.3.4. asterisk-form 1987 The asterisk-form of request-target is only used for a server-wide 1988 OPTIONS request (Section 4.3.7 of [SEMNTCS]). 1990 asterisk-form = "*" 1992 When a client wishes to request OPTIONS for the server as a whole, as 1993 opposed to a specific named resource of that server, the client MUST 1994 send only "*" (%x2A) as the request-target. For example, 1996 OPTIONS * HTTP/1.1 1998 If a proxy receives an OPTIONS request with an absolute-form of 1999 request-target in which the URI has an empty path and no query 2000 component, then the last proxy on the request chain MUST send a 2001 request-target of "*" when it forwards the request to the indicated 2002 origin server. 2004 For example, the request 2006 OPTIONS http://www.example.org:8001 HTTP/1.1 2008 would be forwarded by the final proxy as 2010 OPTIONS * HTTP/1.1 2011 Host: www.example.org:8001 2013 after connecting to port 8001 of host "www.example.org". 2015 5.4. Host 2017 The "Host" header field in a request provides the host and port 2018 information from the target URI, enabling the origin server to 2019 distinguish among resources while servicing requests for multiple 2020 host names on a single IP address. 2022 Host = uri-host [ ":" port ] ; Section 2.7.1 2024 A client MUST send a Host header field in all HTTP/1.1 request 2025 messages. If the target URI includes an authority component, then a 2026 client MUST send a field-value for Host that is identical to that 2027 authority component, excluding any userinfo subcomponent and its "@" 2028 delimiter (Section 2.7.1). If the authority component is missing or 2029 undefined for the target URI, then a client MUST send a Host header 2030 field with an empty field-value. 2032 Since the Host field-value is critical information for handling a 2033 request, a user agent SHOULD generate Host as the first header field 2034 following the request-line. 2036 For example, a GET request to the origin server for 2037 would begin with: 2039 GET /pub/WWW/ HTTP/1.1 2040 Host: www.example.org 2042 A client MUST send a Host header field in an HTTP/1.1 request even if 2043 the request-target is in the absolute-form, since this allows the 2044 Host information to be forwarded through ancient HTTP/1.0 proxies 2045 that might not have implemented Host. 2047 When a proxy receives a request with an absolute-form of request- 2048 target, the proxy MUST ignore the received Host header field (if any) 2049 and instead replace it with the host information of the request- 2050 target. A proxy that forwards such a request MUST generate a new 2051 Host field-value based on the received request-target rather than 2052 forward the received Host field-value. 2054 Since the Host header field acts as an application-level routing 2055 mechanism, it is a frequent target for malware seeking to poison a 2056 shared cache or redirect a request to an unintended server. An 2057 interception proxy is particularly vulnerable if it relies on the 2058 Host field-value for redirecting requests to internal servers, or for 2059 use as a cache key in a shared cache, without first verifying that 2060 the intercepted connection is targeting a valid IP address for that 2061 host. 2063 A server MUST respond with a 400 (Bad Request) status code to any 2064 HTTP/1.1 request message that lacks a Host header field and to any 2065 request message that contains more than one Host header field or a 2066 Host header field with an invalid field-value. 2068 5.5. Effective Request URI 2070 Since the request-target often contains only part of the user agent's 2071 target URI, a server reconstructs the intended target as an 2072 "effective request URI" to properly service the request. This 2073 reconstruction involves both the server's local configuration and 2074 information communicated in the request-target, Host header field, 2075 and connection context. 2077 For a user agent, the effective request URI is the target URI. 2079 If the request-target is in absolute-form, the effective request URI 2080 is the same as the request-target. Otherwise, the effective request 2081 URI is constructed as follows: 2083 If the server's configuration (or outbound gateway) provides a 2084 fixed URI scheme, that scheme is used for the effective request 2085 URI. Otherwise, if the request is received over a TLS-secured TCP 2086 connection, the effective request URI's scheme is "https"; if not, 2087 the scheme is "http". 2089 If the server's configuration (or outbound gateway) provides a 2090 fixed URI authority component, that authority is used for the 2091 effective request URI. If not, then if the request-target is in 2092 authority-form, the effective request URI's authority component is 2093 the same as the request-target. If not, then if a Host header 2094 field is supplied with a non-empty field-value, the authority 2095 component is the same as the Host field-value. Otherwise, the 2096 authority component is assigned the default name configured for 2097 the server and, if the connection's incoming TCP port number 2098 differs from the default port for the effective request URI's 2099 scheme, then a colon (":") and the incoming port number (in 2100 decimal form) are appended to the authority component. 2102 If the request-target is in authority-form or asterisk-form, the 2103 effective request URI's combined path and query component is 2104 empty. Otherwise, the combined path and query component is the 2105 same as the request-target. 2107 The components of the effective request URI, once determined as 2108 above, can be combined into absolute-URI form by concatenating the 2109 scheme, "://", authority, and combined path and query component. 2111 Example 1: the following message received over an insecure TCP 2112 connection 2114 GET /pub/WWW/TheProject.html HTTP/1.1 2115 Host: www.example.org:8080 2117 has an effective request URI of 2119 http://www.example.org:8080/pub/WWW/TheProject.html 2121 Example 2: the following message received over a TLS-secured TCP 2122 connection 2124 OPTIONS * HTTP/1.1 2125 Host: www.example.org 2127 has an effective request URI of 2129 https://www.example.org 2131 Recipients of an HTTP/1.0 request that lacks a Host header field 2132 might need to use heuristics (e.g., examination of the URI path for 2133 something unique to a particular host) in order to guess the 2134 effective request URI's authority component. 2136 Once the effective request URI has been constructed, an origin server 2137 needs to decide whether or not to provide service for that URI via 2138 the connection in which the request was received. For example, the 2139 request might have been misdirected, deliberately or accidentally, 2140 such that the information within a received request-target or Host 2141 header field differs from the host or port upon which the connection 2142 has been made. If the connection is from a trusted gateway, that 2143 inconsistency might be expected; otherwise, it might indicate an 2144 attempt to bypass security filters, trick the server into delivering 2145 non-public content, or poison a cache. See Section 9 for security 2146 considerations regarding message routing. 2148 5.6. Associating a Response to a Request 2150 HTTP does not include a request identifier for associating a given 2151 request message with its corresponding one or more response messages. 2152 Hence, it relies on the order of response arrival to correspond 2153 exactly to the order in which requests are made on the same 2154 connection. More than one response message per request only occurs 2155 when one or more informational responses (1xx, see Section 6.2 of 2156 [SEMNTCS]) precede a final response to the same request. 2158 A client that has more than one outstanding request on a connection 2159 MUST maintain a list of outstanding requests in the order sent and 2160 MUST associate each received response message on that connection to 2161 the highest ordered request that has not yet received a final (non- 2162 1xx) response. 2164 5.7. Message Forwarding 2166 As described in Section 2.3, intermediaries can serve a variety of 2167 roles in the processing of HTTP requests and responses. Some 2168 intermediaries are used to improve performance or availability. 2169 Others are used for access control or to filter content. Since an 2170 HTTP stream has characteristics similar to a pipe-and-filter 2171 architecture, there are no inherent limits to the extent an 2172 intermediary can enhance (or interfere) with either direction of the 2173 stream. 2175 An intermediary not acting as a tunnel MUST implement the Connection 2176 header field, as specified in Section 6.1, and exclude fields from 2177 being forwarded that are only intended for the incoming connection. 2179 An intermediary MUST NOT forward a message to itself unless it is 2180 protected from an infinite request loop. In general, an intermediary 2181 ought to recognize its own server names, including any aliases, local 2182 variations, or literal IP addresses, and respond to such requests 2183 directly. 2185 5.7.1. Via 2187 The "Via" header field indicates the presence of intermediate 2188 protocols and recipients between the user agent and the server (on 2189 requests) or between the origin server and the client (on responses), 2190 similar to the "Received" header field in email (Section 3.6.7 of 2191 [RFC5322]). Via can be used for tracking message forwards, avoiding 2192 request loops, and identifying the protocol capabilities of senders 2193 along the request/response chain. 2195 Via = 1#( received-protocol RWS received-by [ RWS comment ] ) 2197 received-protocol = [ protocol-name "/" ] protocol-version 2198 ; see Section 6.7 2199 received-by = ( uri-host [ ":" port ] ) / pseudonym 2200 pseudonym = token 2202 Multiple Via field values represent each proxy or gateway that has 2203 forwarded the message. Each intermediary appends its own information 2204 about how the message was received, such that the end result is 2205 ordered according to the sequence of forwarding recipients. 2207 A proxy MUST send an appropriate Via header field, as described 2208 below, in each message that it forwards. An HTTP-to-HTTP gateway 2209 MUST send an appropriate Via header field in each inbound request 2210 message and MAY send a Via header field in forwarded response 2211 messages. 2213 For each intermediary, the received-protocol indicates the protocol 2214 and protocol version used by the upstream sender of the message. 2215 Hence, the Via field value records the advertised protocol 2216 capabilities of the request/response chain such that they remain 2217 visible to downstream recipients; this can be useful for determining 2218 what backwards-incompatible features might be safe to use in 2219 response, or within a later request, as described in Section 2.6. 2220 For brevity, the protocol-name is omitted when the received protocol 2221 is HTTP. 2223 The received-by portion of the field value is normally the host and 2224 optional port number of a recipient server or client that 2225 subsequently forwarded the message. However, if the real host is 2226 considered to be sensitive information, a sender MAY replace it with 2227 a pseudonym. If a port is not provided, a recipient MAY interpret 2228 that as meaning it was received on the default TCP port, if any, for 2229 the received-protocol. 2231 A sender MAY generate comments in the Via header field to identify 2232 the software of each recipient, analogous to the User-Agent and 2233 Server header fields. However, all comments in the Via field are 2234 optional, and a recipient MAY remove them prior to forwarding the 2235 message. 2237 For example, a request message could be sent from an HTTP/1.0 user 2238 agent to an internal proxy code-named "fred", which uses HTTP/1.1 to 2239 forward the request to a public proxy at p.example.net, which 2240 completes the request by forwarding it to the origin server at 2241 www.example.com. The request received by www.example.com would then 2242 have the following Via header field: 2244 Via: 1.0 fred, 1.1 p.example.net 2246 An intermediary used as a portal through a network firewall SHOULD 2247 NOT forward the names and ports of hosts within the firewall region 2248 unless it is explicitly enabled to do so. If not enabled, such an 2249 intermediary SHOULD replace each received-by host of any host behind 2250 the firewall by an appropriate pseudonym for that host. 2252 An intermediary MAY combine an ordered subsequence of Via header 2253 field entries into a single such entry if the entries have identical 2254 received-protocol values. For example, 2256 Via: 1.0 ricky, 1.1 ethel, 1.1 fred, 1.0 lucy 2258 could be collapsed to 2260 Via: 1.0 ricky, 1.1 mertz, 1.0 lucy 2262 A sender SHOULD NOT combine multiple entries unless they are all 2263 under the same organizational control and the hosts have already been 2264 replaced by pseudonyms. A sender MUST NOT combine entries that have 2265 different received-protocol values. 2267 5.7.2. Transformations 2269 Some intermediaries include features for transforming messages and 2270 their payloads. A proxy might, for example, convert between image 2271 formats in order to save cache space or to reduce the amount of 2272 traffic on a slow link. However, operational problems might occur 2273 when these transformations are applied to payloads intended for 2274 critical applications, such as medical imaging or scientific data 2275 analysis, particularly when integrity checks or digital signatures 2276 are used to ensure that the payload received is identical to the 2277 original. 2279 An HTTP-to-HTTP proxy is called a "transforming proxy" if it is 2280 designed or configured to modify messages in a semantically 2281 meaningful way (i.e., modifications, beyond those required by normal 2282 HTTP processing, that change the message in a way that would be 2283 significant to the original sender or potentially significant to 2284 downstream recipients). For example, a transforming proxy might be 2285 acting as a shared annotation server (modifying responses to include 2286 references to a local annotation database), a malware filter, a 2287 format transcoder, or a privacy filter. Such transformations are 2288 presumed to be desired by whichever client (or client organization) 2289 selected the proxy. 2291 If a proxy receives a request-target with a host name that is not a 2292 fully qualified domain name, it MAY add its own domain to the host 2293 name it received when forwarding the request. A proxy MUST NOT 2294 change the host name if the request-target contains a fully qualified 2295 domain name. 2297 A proxy MUST NOT modify the "absolute-path" and "query" parts of the 2298 received request-target when forwarding it to the next inbound 2299 server, except as noted above to replace an empty path with "/" or 2300 "*". 2302 A proxy MAY modify the message body through application or removal of 2303 a transfer coding (Section 4). 2305 A proxy MUST NOT transform the payload (Section 3.3 of [SEMNTCS]) of 2306 a message that contains a no-transform cache-control directive 2307 (Section 5.2 of [CACHING]). 2309 A proxy MAY transform the payload of a message that does not contain 2310 a no-transform cache-control directive. A proxy that transforms a 2311 payload MUST add a Warning header field with the warn-code of 214 2312 ("Transformation Applied") if one is not already in the message (see 2313 Section 5.5 of [CACHING]). A proxy that transforms the payload of a 2314 200 (OK) response can further inform downstream recipients that a 2315 transformation has been applied by changing the response status code 2316 to 203 (Non-Authoritative Information) (Section 6.3.4 of [SEMNTCS]). 2318 A proxy SHOULD NOT modify header fields that provide information 2319 about the endpoints of the communication chain, the resource state, 2320 or the selected representation (other than the payload) unless the 2321 field's definition specifically allows such modification or the 2322 modification is deemed necessary for privacy or security. 2324 6. Connection Management 2326 HTTP messaging is independent of the underlying transport- or 2327 session-layer connection protocol(s). HTTP only presumes a reliable 2328 transport with in-order delivery of requests and the corresponding 2329 in-order delivery of responses. The mapping of HTTP request and 2330 response structures onto the data units of an underlying transport 2331 protocol is outside the scope of this specification. 2333 As described in Section 5.2, the specific connection protocols to be 2334 used for an HTTP interaction are determined by client configuration 2335 and the target URI. For example, the "http" URI scheme 2336 (Section 2.7.1) indicates a default connection of TCP over IP, with a 2337 default TCP port of 80, but the client might be configured to use a 2338 proxy via some other connection, port, or protocol. 2340 HTTP implementations are expected to engage in connection management, 2341 which includes maintaining the state of current connections, 2342 establishing a new connection or reusing an existing connection, 2343 processing messages received on a connection, detecting connection 2344 failures, and closing each connection. Most clients maintain 2345 multiple connections in parallel, including more than one connection 2346 per server endpoint. Most servers are designed to maintain thousands 2347 of concurrent connections, while controlling request queues to enable 2348 fair use and detect denial-of-service attacks. 2350 6.1. Connection 2352 The "Connection" header field allows the sender to indicate desired 2353 control options for the current connection. In order to avoid 2354 confusing downstream recipients, a proxy or gateway MUST remove or 2355 replace any received connection options before forwarding the 2356 message. 2358 When a header field aside from Connection is used to supply control 2359 information for or about the current connection, the sender MUST list 2360 the corresponding field-name within the Connection header field. A 2361 proxy or gateway MUST parse a received Connection header field before 2362 a message is forwarded and, for each connection-option in this field, 2363 remove any header field(s) from the message with the same name as the 2364 connection-option, and then remove the Connection header field itself 2365 (or replace it with the intermediary's own connection options for the 2366 forwarded message). 2368 Hence, the Connection header field provides a declarative way of 2369 distinguishing header fields that are only intended for the immediate 2370 recipient ("hop-by-hop") from those fields that are intended for all 2371 recipients on the chain ("end-to-end"), enabling the message to be 2372 self-descriptive and allowing future connection-specific extensions 2373 to be deployed without fear that they will be blindly forwarded by 2374 older intermediaries. 2376 The Connection header field's value has the following grammar: 2378 Connection = 1#connection-option 2379 connection-option = token 2381 Connection options are case-insensitive. 2383 A sender MUST NOT send a connection option corresponding to a header 2384 field that is intended for all recipients of the payload. For 2385 example, Cache-Control is never appropriate as a connection option 2386 (Section 5.2 of [CACHING]). 2388 The connection options do not always correspond to a header field 2389 present in the message, since a connection-specific header field 2390 might not be needed if there are no parameters associated with a 2391 connection option. In contrast, a connection-specific header field 2392 that is received without a corresponding connection option usually 2393 indicates that the field has been improperly forwarded by an 2394 intermediary and ought to be ignored by the recipient. 2396 When defining new connection options, specification authors ought to 2397 survey existing header field names and ensure that the new connection 2398 option does not share the same name as an already deployed header 2399 field. Defining a new connection option essentially reserves that 2400 potential field-name for carrying additional information related to 2401 the connection option, since it would be unwise for senders to use 2402 that field-name for anything else. 2404 The "close" connection option is defined for a sender to signal that 2405 this connection will be closed after completion of the response. For 2406 example, 2408 Connection: close 2410 in either the request or the response header fields indicates that 2411 the sender is going to close the connection after the current 2412 request/response is complete (Section 6.6). 2414 A client that does not support persistent connections MUST send the 2415 "close" connection option in every request message. 2417 A server that does not support persistent connections MUST send the 2418 "close" connection option in every response message that does not 2419 have a 1xx (Informational) status code. 2421 6.2. Establishment 2423 It is beyond the scope of this specification to describe how 2424 connections are established via various transport- or session-layer 2425 protocols. Each connection applies to only one transport link. 2427 6.3. Persistence 2429 HTTP/1.1 defaults to the use of "persistent connections", allowing 2430 multiple requests and responses to be carried over a single 2431 connection. The "close" connection option is used to signal that a 2432 connection will not persist after the current request/response. HTTP 2433 implementations SHOULD support persistent connections. 2435 A recipient determines whether a connection is persistent or not 2436 based on the most recently received message's protocol version and 2437 Connection header field (if any): 2439 o If the "close" connection option is present, the connection will 2440 not persist after the current response; else, 2442 o If the received protocol is HTTP/1.1 (or later), the connection 2443 will persist after the current response; else, 2445 o If the received protocol is HTTP/1.0, the "keep-alive" connection 2446 option is present, the recipient is not a proxy, and the recipient 2447 wishes to honor the HTTP/1.0 "keep-alive" mechanism, the 2448 connection will persist after the current response; otherwise, 2450 o The connection will close after the current response. 2452 A client MAY send additional requests on a persistent connection 2453 until it sends or receives a "close" connection option or receives an 2454 HTTP/1.0 response without a "keep-alive" connection option. 2456 In order to remain persistent, all messages on a connection need to 2457 have a self-defined message length (i.e., one not defined by closure 2458 of the connection), as described in Section 3.3. A server MUST read 2459 the entire request message body or close the connection after sending 2460 its response, since otherwise the remaining data on a persistent 2461 connection would be misinterpreted as the next request. Likewise, a 2462 client MUST read the entire response message body if it intends to 2463 reuse the same connection for a subsequent request. 2465 A proxy server MUST NOT maintain a persistent connection with an 2466 HTTP/1.0 client (see Section 19.7.1 of [RFC2068] for information and 2467 discussion of the problems with the Keep-Alive header field 2468 implemented by many HTTP/1.0 clients). 2470 See Appendix A.1.2 for more information on backwards compatibility 2471 with HTTP/1.0 clients. 2473 6.3.1. Retrying Requests 2475 Connections can be closed at any time, with or without intention. 2476 Implementations ought to anticipate the need to recover from 2477 asynchronous close events. 2479 When an inbound connection is closed prematurely, a client MAY open a 2480 new connection and automatically retransmit an aborted sequence of 2481 requests if all of those requests have idempotent methods 2482 (Section 4.2.2 of [SEMNTCS]). A proxy MUST NOT automatically retry 2483 non-idempotent requests. 2485 A user agent MUST NOT automatically retry a request with a non- 2486 idempotent method unless it has some means to know that the request 2487 semantics are actually idempotent, regardless of the method, or some 2488 means to detect that the original request was never applied. For 2489 example, a user agent that knows (through design or configuration) 2490 that a POST request to a given resource is safe can repeat that 2491 request automatically. Likewise, a user agent designed specifically 2492 to operate on a version control repository might be able to recover 2493 from partial failure conditions by checking the target resource 2494 revision(s) after a failed connection, reverting or fixing any 2495 changes that were partially applied, and then automatically retrying 2496 the requests that failed. 2498 A client SHOULD NOT automatically retry a failed automatic retry. 2500 6.3.2. Pipelining 2502 A client that supports persistent connections MAY "pipeline" its 2503 requests (i.e., send multiple requests without waiting for each 2504 response). A server MAY process a sequence of pipelined requests in 2505 parallel if they all have safe methods (Section 4.2.1 of [SEMNTCS]), 2506 but it MUST send the corresponding responses in the same order that 2507 the requests were received. 2509 A client that pipelines requests SHOULD retry unanswered requests if 2510 the connection closes before it receives all of the corresponding 2511 responses. When retrying pipelined requests after a failed 2512 connection (a connection not explicitly closed by the server in its 2513 last complete response), a client MUST NOT pipeline immediately after 2514 connection establishment, since the first remaining request in the 2515 prior pipeline might have caused an error response that can be lost 2516 again if multiple requests are sent on a prematurely closed 2517 connection (see the TCP reset problem described in Section 6.6). 2519 Idempotent methods (Section 4.2.2 of [SEMNTCS]) are significant to 2520 pipelining because they can be automatically retried after a 2521 connection failure. A user agent SHOULD NOT pipeline requests after 2522 a non-idempotent method, until the final response status code for 2523 that method has been received, unless the user agent has a means to 2524 detect and recover from partial failure conditions involving the 2525 pipelined sequence. 2527 An intermediary that receives pipelined requests MAY pipeline those 2528 requests when forwarding them inbound, since it can rely on the 2529 outbound user agent(s) to determine what requests can be safely 2530 pipelined. If the inbound connection fails before receiving a 2531 response, the pipelining intermediary MAY attempt to retry a sequence 2532 of requests that have yet to receive a response if the requests all 2533 have idempotent methods; otherwise, the pipelining intermediary 2534 SHOULD forward any received responses and then close the 2535 corresponding outbound connection(s) so that the outbound user 2536 agent(s) can recover accordingly. 2538 6.4. Concurrency 2540 A client ought to limit the number of simultaneous open connections 2541 that it maintains to a given server. 2543 Previous revisions of HTTP gave a specific number of connections as a 2544 ceiling, but this was found to be impractical for many applications. 2545 As a result, this specification does not mandate a particular maximum 2546 number of connections but, instead, encourages clients to be 2547 conservative when opening multiple connections. 2549 Multiple connections are typically used to avoid the "head-of-line 2550 blocking" problem, wherein a request that takes significant server- 2551 side processing and/or has a large payload blocks subsequent requests 2552 on the same connection. However, each connection consumes server 2553 resources. Furthermore, using multiple connections can cause 2554 undesirable side effects in congested networks. 2556 Note that a server might reject traffic that it deems abusive or 2557 characteristic of a denial-of-service attack, such as an excessive 2558 number of open connections from a single client. 2560 6.5. Failures and Timeouts 2562 Servers will usually have some timeout value beyond which they will 2563 no longer maintain an inactive connection. Proxy servers might make 2564 this a higher value since it is likely that the client will be making 2565 more connections through the same proxy server. The use of 2566 persistent connections places no requirements on the length (or 2567 existence) of this timeout for either the client or the server. 2569 A client or server that wishes to time out SHOULD issue a graceful 2570 close on the connection. Implementations SHOULD constantly monitor 2571 open connections for a received closure signal and respond to it as 2572 appropriate, since prompt closure of both sides of a connection 2573 enables allocated system resources to be reclaimed. 2575 A client, server, or proxy MAY close the transport connection at any 2576 time. For example, a client might have started to send a new request 2577 at the same time that the server has decided to close the "idle" 2578 connection. From the server's point of view, the connection is being 2579 closed while it was idle, but from the client's point of view, a 2580 request is in progress. 2582 A server SHOULD sustain persistent connections, when possible, and 2583 allow the underlying transport's flow-control mechanisms to resolve 2584 temporary overloads, rather than terminate connections with the 2585 expectation that clients will retry. The latter technique can 2586 exacerbate network congestion. 2588 A client sending a message body SHOULD monitor the network connection 2589 for an error response while it is transmitting the request. If the 2590 client sees a response that indicates the server does not wish to 2591 receive the message body and is closing the connection, the client 2592 SHOULD immediately cease transmitting the body and close its side of 2593 the connection. 2595 6.6. Tear-down 2597 The Connection header field (Section 6.1) provides a "close" 2598 connection option that a sender SHOULD send when it wishes to close 2599 the connection after the current request/response pair. 2601 A client that sends a "close" connection option MUST NOT send further 2602 requests on that connection (after the one containing "close") and 2603 MUST close the connection after reading the final response message 2604 corresponding to this request. 2606 A server that receives a "close" connection option MUST initiate a 2607 close of the connection (see below) after it sends the final response 2608 to the request that contained "close". The server SHOULD send a 2609 "close" connection option in its final response on that connection. 2610 The server MUST NOT process any further requests received on that 2611 connection. 2613 A server that sends a "close" connection option MUST initiate a close 2614 of the connection (see below) after it sends the response containing 2615 "close". The server MUST NOT process any further requests received 2616 on that connection. 2618 A client that receives a "close" connection option MUST cease sending 2619 requests on that connection and close the connection after reading 2620 the response message containing the "close"; if additional pipelined 2621 requests had been sent on the connection, the client SHOULD NOT 2622 assume that they will be processed by the server. 2624 If a server performs an immediate close of a TCP connection, there is 2625 a significant risk that the client will not be able to read the last 2626 HTTP response. If the server receives additional data from the 2627 client on a fully closed connection, such as another request that was 2628 sent by the client before receiving the server's response, the 2629 server's TCP stack will send a reset packet to the client; 2630 unfortunately, the reset packet might erase the client's 2631 unacknowledged input buffers before they can be read and interpreted 2632 by the client's HTTP parser. 2634 To avoid the TCP reset problem, servers typically close a connection 2635 in stages. First, the server performs a half-close by closing only 2636 the write side of the read/write connection. The server then 2637 continues to read from the connection until it receives a 2638 corresponding close by the client, or until the server is reasonably 2639 certain that its own TCP stack has received the client's 2640 acknowledgement of the packet(s) containing the server's last 2641 response. Finally, the server fully closes the connection. 2643 It is unknown whether the reset problem is exclusive to TCP or might 2644 also be found in other transport connection protocols. 2646 6.7. Upgrade 2648 The "Upgrade" header field is intended to provide a simple mechanism 2649 for transitioning from HTTP/1.1 to some other protocol on the same 2650 connection. A client MAY send a list of protocols in the Upgrade 2651 header field of a request to invite the server to switch to one or 2652 more of those protocols, in order of descending preference, before 2653 sending the final response. A server MAY ignore a received Upgrade 2654 header field if it wishes to continue using the current protocol on 2655 that connection. Upgrade cannot be used to insist on a protocol 2656 change. 2658 Upgrade = 1#protocol 2660 protocol = protocol-name ["/" protocol-version] 2661 protocol-name = token 2662 protocol-version = token 2664 A server that sends a 101 (Switching Protocols) response MUST send an 2665 Upgrade header field to indicate the new protocol(s) to which the 2666 connection is being switched; if multiple protocol layers are being 2667 switched, the sender MUST list the protocols in layer-ascending 2668 order. A server MUST NOT switch to a protocol that was not indicated 2669 by the client in the corresponding request's Upgrade header field. A 2670 server MAY choose to ignore the order of preference indicated by the 2671 client and select the new protocol(s) based on other factors, such as 2672 the nature of the request or the current load on the server. 2674 A server that sends a 426 (Upgrade Required) response MUST send an 2675 Upgrade header field to indicate the acceptable protocols, in order 2676 of descending preference. 2678 A server MAY send an Upgrade header field in any other response to 2679 advertise that it implements support for upgrading to the listed 2680 protocols, in order of descending preference, when appropriate for a 2681 future request. 2683 The following is a hypothetical example sent by a client: 2685 GET /hello.txt HTTP/1.1 2686 Host: www.example.com 2687 Connection: upgrade 2688 Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11 2690 The capabilities and nature of the application-level communication 2691 after the protocol change is entirely dependent upon the new 2692 protocol(s) chosen. However, immediately after sending the 101 2693 (Switching Protocols) response, the server is expected to continue 2694 responding to the original request as if it had received its 2695 equivalent within the new protocol (i.e., the server still has an 2696 outstanding request to satisfy after the protocol has been changed, 2697 and is expected to do so without requiring the request to be 2698 repeated). 2700 For example, if the Upgrade header field is received in a GET request 2701 and the server decides to switch protocols, it first responds with a 2702 101 (Switching Protocols) message in HTTP/1.1 and then immediately 2703 follows that with the new protocol's equivalent of a response to a 2704 GET on the target resource. This allows a connection to be upgraded 2705 to protocols with the same semantics as HTTP without the latency cost 2706 of an additional round trip. A server MUST NOT switch protocols 2707 unless the received message semantics can be honored by the new 2708 protocol; an OPTIONS request can be honored by any protocol. 2710 The following is an example response to the above hypothetical 2711 request: 2713 HTTP/1.1 101 Switching Protocols 2714 Connection: upgrade 2715 Upgrade: HTTP/2.0 2717 [... data stream switches to HTTP/2.0 with an appropriate response 2718 (as defined by new protocol) to the "GET /hello.txt" request ...] 2720 When Upgrade is sent, the sender MUST also send a Connection header 2721 field (Section 6.1) that contains an "upgrade" connection option, in 2722 order to prevent Upgrade from being accidentally forwarded by 2723 intermediaries that might not implement the listed protocols. A 2724 server MUST ignore an Upgrade header field that is received in an 2725 HTTP/1.0 request. 2727 A client cannot begin using an upgraded protocol on the connection 2728 until it has completely sent the request message (i.e., the client 2729 can't change the protocol it is sending in the middle of a message). 2730 If a server receives both an Upgrade and an Expect header field with 2731 the "100-continue" expectation (Section 5.1.1 of [SEMNTCS]), the 2732 server MUST send a 100 (Continue) response before sending a 101 2733 (Switching Protocols) response. 2735 The Upgrade header field only applies to switching protocols on top 2736 of the existing connection; it cannot be used to switch the 2737 underlying connection (transport) protocol, nor to switch the 2738 existing communication to a different connection. For those 2739 purposes, it is more appropriate to use a 3xx (Redirection) response 2740 (Section 6.4 of [SEMNTCS]). 2742 This specification only defines the protocol name "HTTP" for use by 2743 the family of Hypertext Transfer Protocols, as defined by the HTTP 2744 version rules of Section 2.6 and future updates to this 2745 specification. Additional tokens ought to be registered with IANA 2746 using the registration procedure defined in Section 8.6. 2748 7. ABNF List Extension: #rule 2750 A #rule extension to the ABNF rules of [RFC5234] is used to improve 2751 readability in the definitions of some header field values. 2753 A construct "#" is defined, similar to "*", for defining comma- 2754 delimited lists of elements. The full form is "#element" 2755 indicating at least and at most elements, each separated by a 2756 single comma (",") and optional whitespace (OWS). 2758 In any production that uses the list construct, a sender MUST NOT 2759 generate empty list elements. In other words, a sender MUST generate 2760 lists that satisfy the following syntax: 2762 1#element => element *( OWS "," OWS element ) 2764 and: 2766 #element => [ 1#element ] 2768 and for n >= 1 and m > 1: 2770 #element => element *( OWS "," OWS element ) 2772 For compatibility with legacy list rules, a recipient MUST parse and 2773 ignore a reasonable number of empty list elements: enough to handle 2774 common mistakes by senders that merge values, but not so much that 2775 they could be used as a denial-of-service mechanism. In other words, 2776 a recipient MUST accept lists that satisfy the following syntax: 2778 #element => [ ( "," / element ) *( OWS "," [ OWS element ] ) ] 2780 1#element => *( "," OWS ) element *( OWS "," [ OWS element ] ) 2782 Empty elements do not contribute to the count of elements present. 2783 For example, given these ABNF productions: 2785 example-list = 1#example-list-elmt 2786 example-list-elmt = token ; see Section 3.2.6 2788 Then the following are valid values for example-list (not including 2789 the double quotes, which are present for delimitation only): 2791 "foo,bar" 2792 "foo ,bar," 2793 "foo , ,bar,charlie " 2795 In contrast, the following values would be invalid, since at least 2796 one non-empty element is required by the example-list production: 2798 "" 2799 "," 2800 ", ," 2802 Appendix B shows the collected ABNF for recipients after the list 2803 constructs have been expanded. 2805 8. IANA Considerations 2807 8.1. Header Field Registration 2809 HTTP header fields are registered within the "Message Headers" 2810 registry maintained at . 2813 This document defines the following HTTP header fields, so the 2814 "Permanent Message Header Field Names" registry has been updated 2815 accordingly (see [BCP90]). 2817 +-------------------+----------+----------+----------------+ 2818 | Header Field Name | Protocol | Status | Reference | 2819 +-------------------+----------+----------+----------------+ 2820 | Connection | http | standard | Section 6.1 | 2821 | Content-Length | http | standard | Section 3.3.2 | 2822 | Host | http | standard | Section 5.4 | 2823 | TE | http | standard | Section 4.3 | 2824 | Trailer | http | standard | Section 4.4 | 2825 | Transfer-Encoding | http | standard | Section 3.3.1 | 2826 | Upgrade | http | standard | Section 6.7 | 2827 | Via | http | standard | Section 5.7.1 | 2828 +-------------------+----------+----------+----------------+ 2830 Furthermore, the header field-name "Close" has been registered as 2831 "reserved", since using that name as an HTTP header field might 2832 conflict with the "close" connection option of the Connection header 2833 field (Section 6.1). 2835 +-------------------+----------+----------+--------------+ 2836 | Header Field Name | Protocol | Status | Reference | 2837 +-------------------+----------+----------+--------------+ 2838 | Close | http | reserved | Section 8.1 | 2839 +-------------------+----------+----------+--------------+ 2841 The change controller is: "IETF (iesg@ietf.org) - Internet 2842 Engineering Task Force". 2844 8.2. URI Scheme Registration 2846 IANA maintains the registry of URI Schemes [BCP115] at 2847 . 2849 This document defines the following URI schemes, so the "Permanent 2850 URI Schemes" registry has been updated accordingly. 2852 +------------+------------------------------------+---------------+ 2853 | URI Scheme | Description | Reference | 2854 +------------+------------------------------------+---------------+ 2855 | http | Hypertext Transfer Protocol | Section 2.7.1 | 2856 | https | Hypertext Transfer Protocol Secure | Section 2.7.2 | 2857 +------------+------------------------------------+---------------+ 2859 8.3. Internet Media Type Registration 2861 IANA maintains the registry of Internet media types [BCP13] at 2862 . 2864 This document serves as the specification for the Internet media 2865 types "message/http" and "application/http". The following has been 2866 registered with IANA. 2868 8.3.1. Internet Media Type message/http 2870 The message/http type can be used to enclose a single HTTP request or 2871 response message, provided that it obeys the MIME restrictions for 2872 all "message" types regarding line length and encodings. 2874 Type name: message 2876 Subtype name: http 2878 Required parameters: N/A 2880 Optional parameters: version, msgtype 2882 version: The HTTP-version number of the enclosed message (e.g., 2883 "1.1"). If not present, the version can be determined from the 2884 first line of the body. 2886 msgtype: The message type -- "request" or "response". If not 2887 present, the type can be determined from the first line of the 2888 body. 2890 Encoding considerations: only "7bit", "8bit", or "binary" are 2891 permitted 2893 Security considerations: see Section 9 2895 Interoperability considerations: N/A 2897 Published specification: This specification (see Section 8.3.1). 2899 Applications that use this media type: N/A 2901 Fragment identifier considerations: N/A 2903 Additional information: 2905 Magic number(s): N/A 2907 Deprecated alias names for this type: N/A 2909 File extension(s): N/A 2911 Macintosh file type code(s): N/A 2913 Person and email address to contact for further information: 2914 See Authors' Addresses section. 2916 Intended usage: COMMON 2918 Restrictions on usage: N/A 2920 Author: See Authors' Addresses section. 2922 Change controller: IESG 2924 8.3.2. Internet Media Type application/http 2926 The application/http type can be used to enclose a pipeline of one or 2927 more HTTP request or response messages (not intermixed). 2929 Type name: application 2931 Subtype name: http 2933 Required parameters: N/A 2935 Optional parameters: version, msgtype 2937 version: The HTTP-version number of the enclosed messages (e.g., 2938 "1.1"). If not present, the version can be determined from the 2939 first line of the body. 2941 msgtype: The message type -- "request" or "response". If not 2942 present, the type can be determined from the first line of the 2943 body. 2945 Encoding considerations: HTTP messages enclosed by this type are in 2946 "binary" format; use of an appropriate Content-Transfer-Encoding 2947 is required when transmitted via email. 2949 Security considerations: see Section 9 2951 Interoperability considerations: N/A 2953 Published specification: This specification (see Section 8.3.2). 2955 Applications that use this media type: N/A 2957 Fragment identifier considerations: N/A 2959 Additional information: 2961 Deprecated alias names for this type: N/A 2963 Magic number(s): N/A 2965 File extension(s): N/A 2967 Macintosh file type code(s): N/A 2969 Person and email address to contact for further information: 2970 See Authors' Addresses section. 2972 Intended usage: COMMON 2974 Restrictions on usage: N/A 2976 Author: See Authors' Addresses section. 2978 Change controller: IESG 2980 8.4. Transfer Coding Registry 2982 The "HTTP Transfer Coding Registry" defines the namespace for 2983 transfer coding names. It is maintained at 2984 . 2986 8.4.1. Procedure 2988 Registrations MUST include the following fields: 2990 o Name 2992 o Description 2994 o Pointer to specification text 2996 Names of transfer codings MUST NOT overlap with names of content 2997 codings (Section 3.1.2.1 of [SEMNTCS]) unless the encoding 2998 transformation is identical, as is the case for the compression 2999 codings defined in Section 4.2. 3001 Values to be added to this namespace require IETF Review (see 3002 Section 4.1 of [RFC5226]), and MUST conform to the purpose of 3003 transfer coding defined in this specification. 3005 Use of program names for the identification of encoding formats is 3006 not desirable and is discouraged for future encodings. 3008 8.4.2. Registration 3010 The "HTTP Transfer Coding Registry" has been updated with the 3011 registrations below: 3013 +------------+------------------------------------------+-----------+ 3014 | Name | Description | Reference | 3015 +------------+------------------------------------------+-----------+ 3016 | chunked | Transfer in a series of chunks | Section 4 | 3017 | | | .1 | 3018 | compress | UNIX "compress" data format [Welch] | Section 4 | 3019 | | | .2.1 | 3020 | deflate | "deflate" compressed data ([RFC1951]) | Section 4 | 3021 | | inside the "zlib" data format | .2.2 | 3022 | | ([RFC1950]) | | 3023 | gzip | GZIP file format [RFC1952] | Section 4 | 3024 | | | .2.3 | 3025 | x-compress | Deprecated (alias for compress) | Section 4 | 3026 | | | .2.1 | 3027 | x-gzip | Deprecated (alias for gzip) | Section 4 | 3028 | | | .2.3 | 3029 +------------+------------------------------------------+-----------+ 3031 8.5. Content Coding Registration 3033 IANA maintains the "HTTP Content Coding Registry" at 3034 . 3036 The "HTTP Content Coding Registry" has been updated with the 3037 registrations below: 3039 +------------+------------------------------------------+-----------+ 3040 | Name | Description | Reference | 3041 +------------+------------------------------------------+-----------+ 3042 | compress | UNIX "compress" data format [Welch] | Section 4 | 3043 | | | .2.1 | 3044 | deflate | "deflate" compressed data ([RFC1951]) | Section 4 | 3045 | | inside the "zlib" data format | .2.2 | 3046 | | ([RFC1950]) | | 3047 | gzip | GZIP file format [RFC1952] | Section 4 | 3048 | | | .2.3 | 3049 | x-compress | Deprecated (alias for compress) | Section 4 | 3050 | | | .2.1 | 3051 | x-gzip | Deprecated (alias for gzip) | Section 4 | 3052 | | | .2.3 | 3053 +------------+------------------------------------------+-----------+ 3055 8.6. Upgrade Token Registry 3057 The "Hypertext Transfer Protocol (HTTP) Upgrade Token Registry" 3058 defines the namespace for protocol-name tokens used to identify 3059 protocols in the Upgrade header field. The registry is maintained at 3060 . 3062 8.6.1. Procedure 3064 Each registered protocol name is associated with contact information 3065 and an optional set of specifications that details how the connection 3066 will be processed after it has been upgraded. 3068 Registrations happen on a "First Come First Served" basis (see 3069 Section 4.1 of [RFC5226]) and are subject to the following rules: 3071 1. A protocol-name token, once registered, stays registered forever. 3073 2. The registration MUST name a responsible party for the 3074 registration. 3076 3. The registration MUST name a point of contact. 3078 4. The registration MAY name a set of specifications associated with 3079 that token. Such specifications need not be publicly available. 3081 5. The registration SHOULD name a set of expected "protocol-version" 3082 tokens associated with that token at the time of registration. 3084 6. The responsible party MAY change the registration at any time. 3085 The IANA will keep a record of all such changes, and make them 3086 available upon request. 3088 7. The IESG MAY reassign responsibility for a protocol token. This 3089 will normally only be used in the case when a responsible party 3090 cannot be contacted. 3092 8.6.2. Upgrade Token Registration 3094 The "HTTP" entry in the upgrade token registry has been updated with 3095 the registration below: 3097 +-------+----------------------+------------------------+-----------+ 3098 | Value | Description | Expected Version | Reference | 3099 | | | Tokens | | 3100 +-------+----------------------+------------------------+-----------+ 3101 | HTTP | Hypertext Transfer | any DIGIT.DIGIT (e.g, | Section 2 | 3102 | | Protocol | "2.0") | .6 | 3103 +-------+----------------------+------------------------+-----------+ 3105 The responsible party is: "IETF (iesg@ietf.org) - Internet 3106 Engineering Task Force". 3108 9. Security Considerations 3110 This section is meant to inform developers, information providers, 3111 and users of known security considerations relevant to HTTP message 3112 syntax, parsing, and routing. Security considerations about HTTP 3113 semantics and payloads are addressed in [SEMNTCS]. 3115 9.1. Establishing Authority 3117 HTTP relies on the notion of an authoritative response: a response 3118 that has been determined by (or at the direction of) the authority 3119 identified within the target URI to be the most appropriate response 3120 for that request given the state of the target resource at the time 3121 of response message origination. Providing a response from a non- 3122 authoritative source, such as a shared cache, is often useful to 3123 improve performance and availability, but only to the extent that the 3124 source can be trusted or the distrusted response can be safely used. 3126 Unfortunately, establishing authority can be difficult. For example, 3127 phishing is an attack on the user's perception of authority, where 3128 that perception can be misled by presenting similar branding in 3129 hypertext, possibly aided by userinfo obfuscating the authority 3130 component (see Section 2.7.1). User agents can reduce the impact of 3131 phishing attacks by enabling users to easily inspect a target URI 3132 prior to making an action, by prominently distinguishing (or 3133 rejecting) userinfo when present, and by not sending stored 3134 credentials and cookies when the referring document is from an 3135 unknown or untrusted source. 3137 When a registered name is used in the authority component, the "http" 3138 URI scheme (Section 2.7.1) relies on the user's local name resolution 3139 service to determine where it can find authoritative responses. This 3140 means that any attack on a user's network host table, cached names, 3141 or name resolution libraries becomes an avenue for attack on 3142 establishing authority. Likewise, the user's choice of server for 3143 Domain Name Service (DNS), and the hierarchy of servers from which it 3144 obtains resolution results, could impact the authenticity of address 3145 mappings; DNS Security Extensions (DNSSEC, [RFC4033]) are one way to 3146 improve authenticity. 3148 Furthermore, after an IP address is obtained, establishing authority 3149 for an "http" URI is vulnerable to attacks on Internet Protocol 3150 routing. 3152 The "https" scheme (Section 2.7.2) is intended to prevent (or at 3153 least reveal) many of these potential attacks on establishing 3154 authority, provided that the negotiated TLS connection is secured and 3155 the client properly verifies that the communicating server's identity 3156 matches the target URI's authority component (see [RFC2818]). 3157 Correctly implementing such verification can be difficult (see 3158 [Georgiev]). 3160 9.2. Risks of Intermediaries 3162 By their very nature, HTTP intermediaries are men-in-the-middle and, 3163 thus, represent an opportunity for man-in-the-middle attacks. 3164 Compromise of the systems on which the intermediaries run can result 3165 in serious security and privacy problems. Intermediaries might have 3166 access to security-related information, personal information about 3167 individual users and organizations, and proprietary information 3168 belonging to users and content providers. A compromised 3169 intermediary, or an intermediary implemented or configured without 3170 regard to security and privacy considerations, might be used in the 3171 commission of a wide range of potential attacks. 3173 Intermediaries that contain a shared cache are especially vulnerable 3174 to cache poisoning attacks, as described in Section 8 of [CACHING]. 3176 Implementers need to consider the privacy and security implications 3177 of their design and coding decisions, and of the configuration 3178 options they provide to operators (especially the default 3179 configuration). 3181 Users need to be aware that intermediaries are no more trustworthy 3182 than the people who run them; HTTP itself cannot solve this problem. 3184 9.3. Attacks via Protocol Element Length 3186 Because HTTP uses mostly textual, character-delimited fields, parsers 3187 are often vulnerable to attacks based on sending very long (or very 3188 slow) streams of data, particularly where an implementation is 3189 expecting a protocol element with no predefined length. 3191 To promote interoperability, specific recommendations are made for 3192 minimum size limits on request-line (Section 3.1.1) and header fields 3193 (Section 3.2). These are minimum recommendations, chosen to be 3194 supportable even by implementations with limited resources; it is 3195 expected that most implementations will choose substantially higher 3196 limits. 3198 A server can reject a message that has a request-target that is too 3199 long (Section 6.5.12 of [SEMNTCS]) or a request payload that is too 3200 large (Section 6.5.11 of [SEMNTCS]). Additional status codes related 3201 to capacity limits have been defined by extensions to HTTP [RFC6585]. 3203 Recipients ought to carefully limit the extent to which they process 3204 other protocol elements, including (but not limited to) request 3205 methods, response status phrases, header field-names, numeric values, 3206 and body chunks. Failure to limit such processing can result in 3207 buffer overflows, arithmetic overflows, or increased vulnerability to 3208 denial-of-service attacks. 3210 9.4. Response Splitting 3212 Response splitting (a.k.a, CRLF injection) is a common technique, 3213 used in various attacks on Web usage, that exploits the line-based 3214 nature of HTTP message framing and the ordered association of 3215 requests to responses on persistent connections [Klein]. This 3216 technique can be particularly damaging when the requests pass through 3217 a shared cache. 3219 Response splitting exploits a vulnerability in servers (usually 3220 within an application server) where an attacker can send encoded data 3221 within some parameter of the request that is later decoded and echoed 3222 within any of the response header fields of the response. If the 3223 decoded data is crafted to look like the response has ended and a 3224 subsequent response has begun, the response has been split and the 3225 content within the apparent second response is controlled by the 3226 attacker. The attacker can then make any other request on the same 3227 persistent connection and trick the recipients (including 3228 intermediaries) into believing that the second half of the split is 3229 an authoritative answer to the second request. 3231 For example, a parameter within the request-target might be read by 3232 an application server and reused within a redirect, resulting in the 3233 same parameter being echoed in the Location header field of the 3234 response. If the parameter is decoded by the application and not 3235 properly encoded when placed in the response field, the attacker can 3236 send encoded CRLF octets and other content that will make the 3237 application's single response look like two or more responses. 3239 A common defense against response splitting is to filter requests for 3240 data that looks like encoded CR and LF (e.g., "%0D" and "%0A"). 3242 However, that assumes the application server is only performing URI 3243 decoding, rather than more obscure data transformations like charset 3244 transcoding, XML entity translation, base64 decoding, sprintf 3245 reformatting, etc. A more effective mitigation is to prevent 3246 anything other than the server's core protocol libraries from sending 3247 a CR or LF within the header section, which means restricting the 3248 output of header fields to APIs that filter for bad octets and not 3249 allowing application servers to write directly to the protocol 3250 stream. 3252 9.5. Request Smuggling 3254 Request smuggling ([Linhart]) is a technique that exploits 3255 differences in protocol parsing among various recipients to hide 3256 additional requests (which might otherwise be blocked or disabled by 3257 policy) within an apparently harmless request. Like response 3258 splitting, request smuggling can lead to a variety of attacks on HTTP 3259 usage. 3261 This specification has introduced new requirements on request 3262 parsing, particularly with regard to message framing in 3263 Section 3.3.3, to reduce the effectiveness of request smuggling. 3265 9.6. Message Integrity 3267 HTTP does not define a specific mechanism for ensuring message 3268 integrity, instead relying on the error-detection ability of 3269 underlying transport protocols and the use of length or chunk- 3270 delimited framing to detect completeness. Additional integrity 3271 mechanisms, such as hash functions or digital signatures applied to 3272 the content, can be selectively added to messages via extensible 3273 metadata header fields. Historically, the lack of a single integrity 3274 mechanism has been justified by the informal nature of most HTTP 3275 communication. However, the prevalence of HTTP as an information 3276 access mechanism has resulted in its increasing use within 3277 environments where verification of message integrity is crucial. 3279 User agents are encouraged to implement configurable means for 3280 detecting and reporting failures of message integrity such that those 3281 means can be enabled within environments for which integrity is 3282 necessary. For example, a browser being used to view medical history 3283 or drug interaction information needs to indicate to the user when 3284 such information is detected by the protocol to be incomplete, 3285 expired, or corrupted during transfer. Such mechanisms might be 3286 selectively enabled via user agent extensions or the presence of 3287 message integrity metadata in a response. At a minimum, user agents 3288 ought to provide some indication that allows a user to distinguish 3289 between a complete and incomplete response message (Section 3.4) when 3290 such verification is desired. 3292 9.7. Message Confidentiality 3294 HTTP relies on underlying transport protocols to provide message 3295 confidentiality when that is desired. HTTP has been specifically 3296 designed to be independent of the transport protocol, such that it 3297 can be used over many different forms of encrypted connection, with 3298 the selection of such transports being identified by the choice of 3299 URI scheme or within user agent configuration. 3301 The "https" scheme can be used to identify resources that require a 3302 confidential connection, as described in Section 2.7.2. 3304 9.8. Privacy of Server Log Information 3306 A server is in the position to save personal data about a user's 3307 requests over time, which might identify their reading patterns or 3308 subjects of interest. In particular, log information gathered at an 3309 intermediary often contains a history of user agent interaction, 3310 across a multitude of sites, that can be traced to individual users. 3312 HTTP log information is confidential in nature; its handling is often 3313 constrained by laws and regulations. Log information needs to be 3314 securely stored and appropriate guidelines followed for its analysis. 3315 Anonymization of personal information within individual entries 3316 helps, but it is generally not sufficient to prevent real log traces 3317 from being re-identified based on correlation with other access 3318 characteristics. As such, access traces that are keyed to a specific 3319 client are unsafe to publish even if the key is pseudonymous. 3321 To minimize the risk of theft or accidental publication, log 3322 information ought to be purged of personally identifiable 3323 information, including user identifiers, IP addresses, and user- 3324 provided query parameters, as soon as that information is no longer 3325 necessary to support operational needs for security, auditing, or 3326 fraud control. 3328 10. References 3330 10.1. Normative References 3332 [AUTHFRM] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 3333 Protocol (HTTP): Authentication", draft-fielding-httpbis- 3334 http-auth-00 (work in progress), March 2018. 3336 [CACHING] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke, 3337 Ed., "Hypertext Transfer Protocol (HTTP): Caching", draft- 3338 fielding-httpbis-http-cache-00 (work in progress), March 3339 2018. 3341 [CONDTNL] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 3342 Protocol (HTTP): Conditional Requests", draft-fielding- 3343 httpbis-http-conditional-00 (work in progress), March 3344 2018. 3346 [RANGERQ] Fielding, R., Ed., Lafon, Y., Ed., and J. Reschke, Ed., 3347 "Hypertext Transfer Protocol (HTTP): Range Requests", 3348 draft-fielding-httpbis-http-range-00 (work in progress), 3349 March 2018. 3351 [RFC0793] Postel, J., "Transmission Control Protocol", STD 7, 3352 RFC 793, DOI 10.17487/RFC0793, September 1981, 3353 . 3355 [RFC1950] Deutsch, L. and J-L. Gailly, "ZLIB Compressed Data Format 3356 Specification version 3.3", RFC 1950, 3357 DOI 10.17487/RFC1950, May 1996, 3358 . 3360 [RFC1951] Deutsch, P., "DEFLATE Compressed Data Format Specification 3361 version 1.3", RFC 1951, DOI 10.17487/RFC1951, May 1996, 3362 . 3364 [RFC1952] Deutsch, P., Gailly, J-L., Adler, M., Deutsch, L., and G. 3365 Randers-Pehrson, "GZIP file format specification version 3366 4.3", RFC 1952, DOI 10.17487/RFC1952, May 1996, 3367 . 3369 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3370 Requirement Levels", BCP 14, RFC 2119, 3371 DOI 10.17487/RFC2119, March 1997, 3372 . 3374 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 3375 Resource Identifier (URI): Generic Syntax", STD 66, 3376 RFC 3986, DOI 10.17487/RFC3986, January 2005, 3377 . 3379 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 3380 Specifications: ABNF", STD 68, RFC 5234, 3381 DOI 10.17487/RFC5234, January 2008, 3382 . 3384 [SEMNTCS] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 3385 Protocol (HTTP): Semantics and Content", draft-fielding- 3386 httpbis-http-semantics-00 (work in progress), March 2018. 3388 [USASCII] American National Standards Institute, "Coded Character 3389 Set -- 7-bit American Standard Code for Information 3390 Interchange", ANSI X3.4, 1986. 3392 [Welch] Welch, T., "A Technique for High-Performance Data 3393 Compression", IEEE Computer 17(6), June 1984. 3395 10.2. Informative References 3397 [BCP115] Hansen, T., Hardie, T., and L. Masinter, "Guidelines and 3398 Registration Procedures for New URI Schemes", BCP 115, 3399 RFC 4395, February 2006, 3400 . 3402 [BCP13] Freed, N., Klensin, J., and T. Hansen, "Media Type 3403 Specifications and Registration Procedures", BCP 13, 3404 RFC 6838, January 2013, 3405 . 3407 [BCP90] Klyne, G., Nottingham, M., and J. Mogul, "Registration 3408 Procedures for Message Header Fields", BCP 90, RFC 3864, 3409 September 2004, . 3411 [Georgiev] 3412 Georgiev, M., Iyengar, S., Jana, S., Anubhai, R., Boneh, 3413 D., and V. Shmatikov, "The Most Dangerous Code in the 3414 World: Validating SSL Certificates in Non-browser 3415 Software", In Proceedings of the 2012 ACM Conference on 3416 Computer and Communications Security (CCS '12), pp. 38-49, 3417 October 2012, 3418 . 3420 [ISO-8859-1] 3421 International Organization for Standardization, 3422 "Information technology -- 8-bit single-byte coded graphic 3423 character sets -- Part 1: Latin alphabet No. 1", ISO/ 3424 IEC 8859-1:1998, 1998. 3426 [Klein] Klein, A., "Divide and Conquer - HTTP Response Splitting, 3427 Web Cache Poisoning Attacks, and Related Topics", March 3428 2004, . 3431 [Kri2001] Kristol, D., "HTTP Cookies: Standards, Privacy, and 3432 Politics", ACM Transactions on Internet Technology 1(2), 3433 November 2001, . 3435 [Linhart] Linhart, C., Klein, A., Heled, R., and S. Orrin, "HTTP 3436 Request Smuggling", June 2005, 3437 . 3439 [RFC1919] Chatel, M., "Classical versus Transparent IP Proxies", 3440 RFC 1919, DOI 10.17487/RFC1919, March 1996, 3441 . 3443 [RFC1945] Berners-Lee, T., Fielding, R., and H. Nielsen, "Hypertext 3444 Transfer Protocol -- HTTP/1.0", RFC 1945, 3445 DOI 10.17487/RFC1945, May 1996, 3446 . 3448 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 3449 Extensions (MIME) Part One: Format of Internet Message 3450 Bodies", RFC 2045, DOI 10.17487/RFC2045, November 1996, 3451 . 3453 [RFC2047] Moore, K., "MIME (Multipurpose Internet Mail Extensions) 3454 Part Three: Message Header Extensions for Non-ASCII Text", 3455 RFC 2047, DOI 10.17487/RFC2047, November 1996, 3456 . 3458 [RFC2068] Fielding, R., Gettys, J., Mogul, J., Nielsen, H., and T. 3459 Berners-Lee, "Hypertext Transfer Protocol -- HTTP/1.1", 3460 RFC 2068, DOI 10.17487/RFC2068, January 1997, 3461 . 3463 [RFC2145] Mogul, J., Fielding, R., Gettys, J., and H. Nielsen, "Use 3464 and Interpretation of HTTP Version Numbers", RFC 2145, 3465 DOI 10.17487/RFC2145, May 1997, 3466 . 3468 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 3469 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 3470 Transfer Protocol -- HTTP/1.1", RFC 2616, 3471 DOI 10.17487/RFC2616, June 1999, 3472 . 3474 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, 3475 DOI 10.17487/RFC2818, May 2000, 3476 . 3478 [RFC3040] Cooper, I., Melve, I., and G. Tomlinson, "Internet Web 3479 Replication and Caching Taxonomy", RFC 3040, 3480 DOI 10.17487/RFC3040, January 2001, 3481 . 3483 [RFC4033] Arends, R., Austein, R., Larson, M., Massey, D., and S. 3484 Rose, "DNS Security Introduction and Requirements", 3485 RFC 4033, DOI 10.17487/RFC4033, March 2005, 3486 . 3488 [RFC4559] Jaganathan, K., Zhu, L., and J. Brezak, "SPNEGO-based 3489 Kerberos and NTLM HTTP Authentication in Microsoft 3490 Windows", RFC 4559, DOI 10.17487/RFC4559, June 2006, 3491 . 3493 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 3494 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 3495 DOI 10.17487/RFC5226, May 2008, 3496 . 3498 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 3499 (TLS) Protocol Version 1.2", RFC 5246, 3500 DOI 10.17487/RFC5246, August 2008, 3501 . 3503 [RFC5322] Resnick, P., "Internet Message Format", RFC 5322, 3504 DOI 10.17487/RFC5322, October 2008, 3505 . 3507 [RFC6265] Barth, A., "HTTP State Management Mechanism", RFC 6265, 3508 DOI 10.17487/RFC6265, April 2011, 3509 . 3511 [RFC6585] Nottingham, M. and R. Fielding, "Additional HTTP Status 3512 Codes", RFC 6585, DOI 10.17487/RFC6585, April 2012, 3513 . 3515 [RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 3516 Protocol (HTTP/1.1): Message Syntax and Routing", 3517 RFC 7230, DOI 10.17487/RFC7230, June 2014, 3518 . 3520 Appendix A. HTTP Version History 3522 HTTP has been in use since 1990. The first version, later referred 3523 to as HTTP/0.9, was a simple protocol for hypertext data transfer 3524 across the Internet, using only a single request method (GET) and no 3525 metadata. HTTP/1.0, as defined by [RFC1945], added a range of 3526 request methods and MIME-like messaging, allowing for metadata to be 3527 transferred and modifiers placed on the request/response semantics. 3528 However, HTTP/1.0 did not sufficiently take into consideration the 3529 effects of hierarchical proxies, caching, the need for persistent 3530 connections, or name-based virtual hosts. The proliferation of 3531 incompletely implemented applications calling themselves "HTTP/1.0" 3532 further necessitated a protocol version change in order for two 3533 communicating applications to determine each other's true 3534 capabilities. 3536 HTTP/1.1 remains compatible with HTTP/1.0 by including more stringent 3537 requirements that enable reliable implementations, adding only those 3538 features that can either be safely ignored by an HTTP/1.0 recipient 3539 or only be sent when communicating with a party advertising 3540 conformance with HTTP/1.1. 3542 HTTP/1.1 has been designed to make supporting previous versions easy. 3543 A general-purpose HTTP/1.1 server ought to be able to understand any 3544 valid request in the format of HTTP/1.0, responding appropriately 3545 with an HTTP/1.1 message that only uses features understood (or 3546 safely ignored) by HTTP/1.0 clients. Likewise, an HTTP/1.1 client 3547 can be expected to understand any valid HTTP/1.0 response. 3549 Since HTTP/0.9 did not support header fields in a request, there is 3550 no mechanism for it to support name-based virtual hosts (selection of 3551 resource by inspection of the Host header field). Any server that 3552 implements name-based virtual hosts ought to disable support for 3553 HTTP/0.9. Most requests that appear to be HTTP/0.9 are, in fact, 3554 badly constructed HTTP/1.x requests caused by a client failing to 3555 properly encode the request-target. 3557 A.1. Changes from HTTP/1.0 3559 This section summarizes major differences between versions HTTP/1.0 3560 and HTTP/1.1. 3562 A.1.1. Multihomed Web Servers 3564 The requirements that clients and servers support the Host header 3565 field (Section 5.4), report an error if it is missing from an 3566 HTTP/1.1 request, and accept absolute URIs (Section 5.3) are among 3567 the most important changes defined by HTTP/1.1. 3569 Older HTTP/1.0 clients assumed a one-to-one relationship of IP 3570 addresses and servers; there was no other established mechanism for 3571 distinguishing the intended server of a request than the IP address 3572 to which that request was directed. The Host header field was 3573 introduced during the development of HTTP/1.1 and, though it was 3574 quickly implemented by most HTTP/1.0 browsers, additional 3575 requirements were placed on all HTTP/1.1 requests in order to ensure 3576 complete adoption. At the time of this writing, most HTTP-based 3577 services are dependent upon the Host header field for targeting 3578 requests. 3580 A.1.2. Keep-Alive Connections 3582 In HTTP/1.0, each connection is established by the client prior to 3583 the request and closed by the server after sending the response. 3584 However, some implementations implement the explicitly negotiated 3585 ("Keep-Alive") version of persistent connections described in 3586 Section 19.7.1 of [RFC2068]. 3588 Some clients and servers might wish to be compatible with these 3589 previous approaches to persistent connections, by explicitly 3590 negotiating for them with a "Connection: keep-alive" request header 3591 field. However, some experimental implementations of HTTP/1.0 3592 persistent connections are faulty; for example, if an HTTP/1.0 proxy 3593 server doesn't understand Connection, it will erroneously forward 3594 that header field to the next inbound server, which would result in a 3595 hung connection. 3597 One attempted solution was the introduction of a Proxy-Connection 3598 header field, targeted specifically at proxies. In practice, this 3599 was also unworkable, because proxies are often deployed in multiple 3600 layers, bringing about the same problem discussed above. 3602 As a result, clients are encouraged not to send the Proxy-Connection 3603 header field in any requests. 3605 Clients are also encouraged to consider the use of Connection: keep- 3606 alive in requests carefully; while they can enable persistent 3607 connections with HTTP/1.0 servers, clients using them will need to 3608 monitor the connection for "hung" requests (which indicate that the 3609 client ought stop sending the header field), and this mechanism ought 3610 not be used by clients at all when a proxy is being used. 3612 A.1.3. Introduction of Transfer-Encoding 3614 HTTP/1.1 introduces the Transfer-Encoding header field 3615 (Section 3.3.1). Transfer codings need to be decoded prior to 3616 forwarding an HTTP message over a MIME-compliant protocol. 3618 A.2. Changes from RFC 7230 3620 None yet. 3622 Appendix B. Collected ABNF 3624 BWS = OWS 3626 Connection = *( "," OWS ) connection-option *( OWS "," [ OWS 3627 connection-option ] ) 3628 Content-Length = 1*DIGIT 3630 HTTP-message = start-line *( header-field CRLF ) CRLF [ message-body 3631 ] 3632 HTTP-name = %x48.54.54.50 ; HTTP 3633 HTTP-version = HTTP-name "/" DIGIT "." DIGIT 3634 Host = uri-host [ ":" port ] 3636 OWS = *( SP / HTAB ) 3638 RWS = 1*( SP / HTAB ) 3640 TE = [ ( "," / t-codings ) *( OWS "," [ OWS t-codings ] ) ] 3641 Trailer = *( "," OWS ) field-name *( OWS "," [ OWS field-name ] ) 3642 Transfer-Encoding = *( "," OWS ) transfer-coding *( OWS "," [ OWS 3643 transfer-coding ] ) 3645 URI-reference = 3646 Upgrade = *( "," OWS ) protocol *( OWS "," [ OWS protocol ] ) 3648 Via = *( "," OWS ) ( received-protocol RWS received-by [ RWS comment 3649 ] ) *( OWS "," [ OWS ( received-protocol RWS received-by [ RWS 3650 comment ] ) ] ) 3652 absolute-URI = 3653 absolute-form = absolute-URI 3654 absolute-path = 1*( "/" segment ) 3655 asterisk-form = "*" 3656 authority = 3657 authority-form = authority 3659 chunk = chunk-size [ chunk-ext ] CRLF chunk-data CRLF 3660 chunk-data = 1*OCTET 3661 chunk-ext = *( ";" chunk-ext-name [ "=" chunk-ext-val ] ) 3662 chunk-ext-name = token 3663 chunk-ext-val = token / quoted-string 3664 chunk-size = 1*HEXDIG 3665 chunked-body = *chunk last-chunk trailer-part CRLF 3666 comment = "(" *( ctext / quoted-pair / comment ) ")" 3667 connection-option = token 3668 ctext = HTAB / SP / %x21-27 ; '!'-''' 3669 / %x2A-5B ; '*'-'[' 3670 / %x5D-7E ; ']'-'~' 3671 / obs-text 3673 field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] 3674 field-name = token 3675 field-value = *( field-content / obs-fold ) 3676 field-vchar = VCHAR / obs-text 3677 fragment = 3679 header-field = field-name ":" OWS field-value OWS 3680 http-URI = "http://" authority path-abempty [ "?" query ] [ "#" 3681 fragment ] 3682 https-URI = "https://" authority path-abempty [ "?" query ] [ "#" 3683 fragment ] 3685 last-chunk = 1*"0" [ chunk-ext ] CRLF 3687 message-body = *OCTET 3688 method = token 3690 obs-fold = CRLF 1*( SP / HTAB ) 3691 obs-text = %x80-FF 3692 origin-form = absolute-path [ "?" query ] 3694 partial-URI = relative-part [ "?" query ] 3695 path-abempty = 3696 port = 3697 protocol = protocol-name [ "/" protocol-version ] 3698 protocol-name = token 3699 protocol-version = token 3700 pseudonym = token 3702 qdtext = HTAB / SP / "!" / %x23-5B ; '#'-'[' 3703 / %x5D-7E ; ']'-'~' 3704 / obs-text 3705 query = 3706 quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) 3707 quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE 3709 rank = ( "0" [ "." *3DIGIT ] ) / ( "1" [ "." *3"0" ] ) 3710 reason-phrase = *( HTAB / SP / VCHAR / obs-text ) 3711 received-by = ( uri-host [ ":" port ] ) / pseudonym 3712 received-protocol = [ protocol-name "/" ] protocol-version 3713 relative-part = 3714 request-line = method SP request-target SP HTTP-version CRLF 3715 request-target = origin-form / absolute-form / authority-form / 3716 asterisk-form 3718 scheme = 3719 segment = 3720 start-line = request-line / status-line 3721 status-code = 3DIGIT 3722 status-line = HTTP-version SP status-code SP reason-phrase CRLF 3724 t-codings = "trailers" / ( transfer-coding [ t-ranking ] ) 3725 t-ranking = OWS ";" OWS "q=" rank 3726 tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / 3727 "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA 3728 token = 1*tchar 3729 trailer-part = *( header-field CRLF ) 3730 transfer-coding = "chunked" / "compress" / "deflate" / "gzip" / 3731 transfer-extension 3732 transfer-extension = token *( OWS ";" OWS transfer-parameter ) 3733 transfer-parameter = token BWS "=" BWS ( token / quoted-string ) 3735 uri-host = 3737 Appendix C. Change Log 3739 This section is to be removed before publishing as an RFC. 3741 C.1. Since RFC 7230 3743 The changes in this draft are purely editorial: 3745 o Change boilerplate and abstract to indicate the "draft" status, 3746 and update references to ancestor specifications. 3748 o Adjust historical notes. 3750 o Update links to sibling specifications. 3752 o Replace sections listing changes from RFC 2616 by new empty 3753 sections referring to RFC 723x. 3755 o Remove acknowledgements specific to RFC 723x. 3757 o Move "Acknowledgements" to the very end and make them unnumbered. 3759 Index 3761 A 3762 absolute-form (of request-target) 41 3763 accelerator 10 3764 application/http Media Type 62 3765 asterisk-form (of request-target) 42 3766 authoritative response 66 3767 authority-form (of request-target) 42 3769 B 3770 browser 7 3772 C 3773 Connection header field 50, 55 3774 Content-Length header field 29 3775 cache 11 3776 cacheable 11 3777 captive portal 11 3778 chunked (Coding Format) 28, 31, 35 3779 client 7 3780 close 50, 55 3781 compress (Coding Format) 38 3782 connection 7 3784 D 3785 Delimiters 26 3786 deflate (Coding Format) 38 3787 downstream 10 3789 E 3790 effective request URI 44 3792 G 3793 Grammar 3794 absolute-form 41 3795 absolute-path 16 3796 absolute-URI 16 3797 ALPHA 6 3798 asterisk-form 41-42 3799 authority 16 3800 authority-form 41-42 3801 BWS 24 3802 chunk 35 3803 chunk-data 35 3804 chunk-ext 35-36 3805 chunk-ext-name 36 3806 chunk-ext-val 36 3807 chunk-size 35 3808 chunked-body 35-36 3809 comment 27 3810 Connection 50 3811 connection-option 50 3812 Content-Length 30 3813 CR 6 3814 CRLF 6 3815 ctext 27 3816 CTL 6 3817 DIGIT 6 3818 DQUOTE 6 3819 field-content 22 3820 field-name 22, 39 3821 field-value 22 3822 field-vchar 22 3823 fragment 16 3824 header-field 22, 36 3825 HEXDIG 6 3826 Host 43 3827 HTAB 6 3828 HTTP-message 19 3829 HTTP-name 14 3830 http-URI 17 3831 HTTP-version 14 3832 https-URI 18 3833 last-chunk 35 3834 LF 6 3835 message-body 27 3836 method 21 3837 obs-fold 22 3838 obs-text 27 3839 OCTET 6 3840 origin-form 41 3841 OWS 24 3842 partial-URI 16 3843 port 16 3844 protocol-name 47 3845 protocol-version 47 3846 pseudonym 47 3847 qdtext 27 3848 query 16 3849 quoted-pair 27 3850 quoted-string 27 3851 rank 38 3852 reason-phrase 22 3853 received-by 47 3854 received-protocol 47 3855 request-line 21 3856 request-target 41 3857 RWS 24 3858 scheme 16 3859 segment 16 3860 SP 6 3861 start-line 20 3862 status-code 22 3863 status-line 22 3864 t-codings 38 3865 t-ranking 38 3866 tchar 26 3867 TE 38 3868 token 26 3869 Trailer 39 3870 trailer-part 35-36 3871 transfer-coding 35 3872 Transfer-Encoding 28 3873 transfer-extension 35 3874 transfer-parameter 35 3875 Upgrade 56 3876 uri-host 16 3877 URI-reference 16 3878 VCHAR 6 3879 Via 47 3880 gateway 10 3881 gzip (Coding Format) 38 3883 H 3884 Host header field 43 3885 header field 19 3886 header section 19 3887 headers 19 3888 http URI scheme 16 3889 https URI scheme 18 3891 I 3892 inbound 10 3893 interception proxy 11 3894 intermediary 9 3896 M 3897 Media Type 3898 application/http 62 3899 message/http 61 3900 message 7 3901 message/http Media Type 61 3902 method 21 3904 N 3905 non-transforming proxy 48 3907 O 3908 origin server 7 3909 origin-form (of request-target) 41 3910 outbound 10 3912 P 3913 phishing 66 3914 proxy 10 3916 R 3917 recipient 7 3918 request 7 3919 request-target 21 3920 resource 16 3921 response 7 3922 reverse proxy 10 3924 S 3925 sender 7 3926 server 7 3927 spider 7 3929 T 3930 TE header field 38 3931 Trailer header field 39 3932 Transfer-Encoding header field 28 3933 target URI 40 3934 target resource 40 3935 transforming proxy 48 3936 transparent proxy 11 3937 tunnel 10 3939 U 3940 URI scheme 3941 http 16 3942 https 18 3943 Upgrade header field 56 3944 upstream 10 3945 user agent 7 3947 V 3948 Via header field 46 3950 Acknowledgments 3952 This edition of the HTTP specification builds on the many 3953 contributions that went into RFC 1945, RFC 2068, RFC 2145, and RFC 3954 2616, including substantial contributions made by the previous 3955 authors, editors, and Working Group Chairs: Tim Berners-Lee, Ari 3956 Luotonen, Roy T. Fielding, Henrik Frystyk Nielsen, Jim Gettys, 3957 Jeffrey C. Mogul, Larry Masinter, and Paul J. Leach. Mark 3958 Nottingham oversaw this effort as Working Group Chair. 3960 See Section 10 of [RFC7230] for additional acknowledgements from 3961 prior revisions. 3963 [[newacks: New acks to be added here.]] 3965 Authors' Addresses 3967 Roy T. Fielding (editor) 3968 Adobe Systems Incorporated 3969 345 Park Ave 3970 San Jose, CA 95110 3971 USA 3973 EMail: fielding@gbiv.com 3974 URI: http://roy.gbiv.com/ 3976 Julian F. Reschke (editor) 3977 greenbytes GmbH 3978 Hafenweg 16 3979 Muenster, NW 48155 3980 Germany 3982 EMail: julian.reschke@greenbytes.de 3983 URI: http://greenbytes.de/tech/webdav/