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