idnits 2.17.1
draft-ietf-httpbis-messaging-09.txt:
Checking boilerplate required by RFC 5378 and the IETF Trust (see
https://trustee.ietf.org/license-info):
----------------------------------------------------------------------------
No issues found here.
Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt:
----------------------------------------------------------------------------
No issues found here.
Checking nits according to https://www.ietf.org/id-info/checklist :
----------------------------------------------------------------------------
-- The draft header indicates that this document obsoletes RFC7230, but the
abstract doesn't seem to directly say this. It does mention RFC7230
though, so this could be OK.
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 (July 11, 2020) is 1378 days in the past. Is this
intentional?
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: 'RFC3986' is defined on line 2108, but no explicit
reference was found in the text
== Unused Reference: 'RFC7231' is defined on line 2195, but no explicit
reference was found in the text
== Outdated reference: A later version (-19) exists of
draft-ietf-httpbis-cache-09
-- Possible downref: Normative reference to a draft: ref. 'Caching'
** 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-09
-- Possible downref: Normative reference to a draft: ref. 'Semantics'
-- Possible downref: Non-RFC (?) normative reference: ref. 'USASCII'
-- Possible downref: Non-RFC (?) normative reference: ref. 'Welch'
-- Obsolete informational reference (is this intentional?): RFC 7230 (ref.
'Err4667') (Obsoleted by RFC 9110, RFC 9112)
-- Obsolete informational reference (is this intentional?): RFC 2068
(Obsoleted by RFC 2616)
-- Duplicate reference: RFC7230, mentioned in 'RFC7230', was also mentioned
in 'Err4667'.
-- Obsolete informational reference (is this intentional?): RFC 7230
(Obsoleted by RFC 9110, RFC 9112)
-- Obsolete informational reference (is this intentional?): RFC 7231
(Obsoleted by RFC 9110)
Summary: 3 errors (**), 0 flaws (~~), 6 warnings (==), 11 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: January 12, 2021 J. Reschke, Ed.
7 greenbytes
8 July 11, 2020
10 HTTP/1.1 Messaging
11 draft-ietf-httpbis-messaging-09
13 Abstract
15 The Hypertext Transfer Protocol (HTTP) is a stateless application-
16 level protocol for distributed, collaborative, hypertext information
17 systems. This document specifies the HTTP/1.1 message syntax,
18 message parsing, connection management, and related security
19 concerns.
21 This document obsoletes portions of RFC 7230.
23 Editorial Note
25 This note is to be removed before publishing as an RFC.
27 Discussion of this draft takes place on the HTTP working group
28 mailing list (ietf-http-wg@w3.org), which is archived at
29 .
31 Working Group information can be found at ;
32 source code and issues list for this draft can be found at
33 .
35 The changes in this draft are summarized in Appendix D.10.
37 Status of This Memo
39 This Internet-Draft is submitted in full conformance with the
40 provisions of BCP 78 and BCP 79.
42 Internet-Drafts are working documents of the Internet Engineering
43 Task Force (IETF). Note that other groups may also distribute
44 working documents as Internet-Drafts. The list of current Internet-
45 Drafts is at https://datatracker.ietf.org/drafts/current/.
47 Internet-Drafts are draft documents valid for a maximum of six months
48 and may be updated, replaced, or obsoleted by other documents at any
49 time. It is inappropriate to use Internet-Drafts as reference
50 material or to cite them other than as "work in progress."
52 This Internet-Draft will expire on January 12, 2021.
54 Copyright Notice
56 Copyright (c) 2020 IETF Trust and the persons identified as the
57 document authors. All rights reserved.
59 This document is subject to BCP 78 and the IETF Trust's Legal
60 Provisions Relating to IETF Documents
61 (https://trustee.ietf.org/license-info) in effect on the date of
62 publication of this document. Please review these documents
63 carefully, as they describe your rights and restrictions with respect
64 to this document. Code Components extracted from this document must
65 include Simplified BSD License text as described in Section 4.e of
66 the Trust Legal Provisions and are provided without warranty as
67 described in the Simplified BSD License.
69 This document may contain material from IETF Documents or IETF
70 Contributions published or made publicly available before November
71 10, 2008. The person(s) controlling the copyright in some of this
72 material may not have granted the IETF Trust the right to allow
73 modifications of such material outside the IETF Standards Process.
74 Without obtaining an adequate license from the person(s) controlling
75 the copyright in such materials, this document may not be modified
76 outside the IETF Standards Process, and derivative works of it may
77 not be created outside the IETF Standards Process, except to format
78 it for publication as an RFC or to translate it into languages other
79 than English.
81 Table of Contents
83 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4
84 1.1. Requirements Notation . . . . . . . . . . . . . . . . . . 5
85 1.2. Syntax Notation . . . . . . . . . . . . . . . . . . . . . 5
86 2. Message . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
87 2.1. Message Format . . . . . . . . . . . . . . . . . . . . . 6
88 2.2. Message Parsing . . . . . . . . . . . . . . . . . . . . . 7
89 2.3. HTTP Version . . . . . . . . . . . . . . . . . . . . . . 8
90 3. Request Line . . . . . . . . . . . . . . . . . . . . . . . . 9
91 3.1. Method . . . . . . . . . . . . . . . . . . . . . . . . . 10
92 3.2. Request Target . . . . . . . . . . . . . . . . . . . . . 10
93 3.2.1. origin-form . . . . . . . . . . . . . . . . . . . . . 10
94 3.2.2. absolute-form . . . . . . . . . . . . . . . . . . . . 11
95 3.2.3. authority-form . . . . . . . . . . . . . . . . . . . 12
96 3.2.4. asterisk-form . . . . . . . . . . . . . . . . . . . . 12
98 3.3. Reconstructing the Target URI . . . . . . . . . . . . . . 13
99 4. Status Line . . . . . . . . . . . . . . . . . . . . . . . . . 14
100 5. Field Syntax . . . . . . . . . . . . . . . . . . . . . . . . 15
101 5.1. Field Line Parsing . . . . . . . . . . . . . . . . . . . 16
102 5.2. Obsolete Line Folding . . . . . . . . . . . . . . . . . . 16
103 6. Message Body . . . . . . . . . . . . . . . . . . . . . . . . 17
104 6.1. Transfer-Encoding . . . . . . . . . . . . . . . . . . . . 18
105 6.2. Content-Length . . . . . . . . . . . . . . . . . . . . . 19
106 6.3. Message Body Length . . . . . . . . . . . . . . . . . . . 20
107 7. Transfer Codings . . . . . . . . . . . . . . . . . . . . . . 22
108 7.1. Chunked Transfer Coding . . . . . . . . . . . . . . . . . 23
109 7.1.1. Chunk Extensions . . . . . . . . . . . . . . . . . . 24
110 7.1.2. Chunked Trailer Section . . . . . . . . . . . . . . . 24
111 7.1.3. Decoding Chunked . . . . . . . . . . . . . . . . . . 25
112 7.2. Transfer Codings for Compression . . . . . . . . . . . . 26
113 7.3. Transfer Coding Registry . . . . . . . . . . . . . . . . 26
114 7.4. TE . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
115 8. Handling Incomplete Messages . . . . . . . . . . . . . . . . 28
116 9. Connection Management . . . . . . . . . . . . . . . . . . . . 28
117 9.1. Connection . . . . . . . . . . . . . . . . . . . . . . . 29
118 9.2. Establishment . . . . . . . . . . . . . . . . . . . . . . 30
119 9.3. Associating a Response to a Request . . . . . . . . . . . 31
120 9.4. Persistence . . . . . . . . . . . . . . . . . . . . . . . 31
121 9.4.1. Retrying Requests . . . . . . . . . . . . . . . . . . 32
122 9.4.2. Pipelining . . . . . . . . . . . . . . . . . . . . . 32
123 9.5. Concurrency . . . . . . . . . . . . . . . . . . . . . . . 33
124 9.6. Failures and Timeouts . . . . . . . . . . . . . . . . . . 33
125 9.7. Tear-down . . . . . . . . . . . . . . . . . . . . . . . . 34
126 9.8. TLS Connection Closure . . . . . . . . . . . . . . . . . 35
127 9.9. Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . 36
128 9.9.1. Upgrade Protocol Names . . . . . . . . . . . . . . . 38
129 9.9.2. Upgrade Token Registry . . . . . . . . . . . . . . . 39
130 10. Enclosing Messages as Data . . . . . . . . . . . . . . . . . 40
131 10.1. Media Type message/http . . . . . . . . . . . . . . . . 40
132 10.2. Media Type application/http . . . . . . . . . . . . . . 41
133 11. Security Considerations . . . . . . . . . . . . . . . . . . . 42
134 11.1. Response Splitting . . . . . . . . . . . . . . . . . . . 42
135 11.2. Request Smuggling . . . . . . . . . . . . . . . . . . . 43
136 11.3. Message Integrity . . . . . . . . . . . . . . . . . . . 43
137 11.4. Message Confidentiality . . . . . . . . . . . . . . . . 44
138 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 44
139 12.1. Field Name Registration . . . . . . . . . . . . . . . . 44
140 12.2. Media Type Registration . . . . . . . . . . . . . . . . 44
141 12.3. Transfer Coding Registration . . . . . . . . . . . . . . 45
142 12.4. Upgrade Token Registration . . . . . . . . . . . . . . . 45
143 12.5. ALPN Protocol ID Registration . . . . . . . . . . . . . 45
144 13. References . . . . . . . . . . . . . . . . . . . . . . . . . 45
145 13.1. Normative References . . . . . . . . . . . . . . . . . . 45
146 13.2. Informative References . . . . . . . . . . . . . . . . . 47
147 Appendix A. Collected ABNF . . . . . . . . . . . . . . . . . . . 49
148 Appendix B. Differences between HTTP and MIME . . . . . . . . . 50
149 B.1. MIME-Version . . . . . . . . . . . . . . . . . . . . . . 51
150 B.2. Conversion to Canonical Form . . . . . . . . . . . . . . 51
151 B.3. Conversion of Date Formats . . . . . . . . . . . . . . . 51
152 B.4. Conversion of Content-Encoding . . . . . . . . . . . . . 52
153 B.5. Conversion of Content-Transfer-Encoding . . . . . . . . . 52
154 B.6. MHTML and Line Length Limitations . . . . . . . . . . . . 52
155 Appendix C. HTTP Version History . . . . . . . . . . . . . . . . 52
156 C.1. Changes from HTTP/1.0 . . . . . . . . . . . . . . . . . . 53
157 C.1.1. Multihomed Web Servers . . . . . . . . . . . . . . . 53
158 C.1.2. Keep-Alive Connections . . . . . . . . . . . . . . . 54
159 C.1.3. Introduction of Transfer-Encoding . . . . . . . . . . 54
160 C.2. Changes from RFC 7230 . . . . . . . . . . . . . . . . . . 54
161 Appendix D. Change Log . . . . . . . . . . . . . . . . . . . . . 55
162 D.1. Between RFC7230 and draft 00 . . . . . . . . . . . . . . 55
163 D.2. Since draft-ietf-httpbis-messaging-00 . . . . . . . . . . 56
164 D.3. Since draft-ietf-httpbis-messaging-01 . . . . . . . . . . 56
165 D.4. Since draft-ietf-httpbis-messaging-02 . . . . . . . . . . 57
166 D.5. Since draft-ietf-httpbis-messaging-03 . . . . . . . . . . 57
167 D.6. Since draft-ietf-httpbis-messaging-04 . . . . . . . . . . 57
168 D.7. Since draft-ietf-httpbis-messaging-05 . . . . . . . . . . 57
169 D.8. Since draft-ietf-httpbis-messaging-06 . . . . . . . . . . 58
170 D.9. Since draft-ietf-httpbis-messaging-07 . . . . . . . . . . 58
171 D.10. Since draft-ietf-httpbis-messaging-08 . . . . . . . . . . 59
172 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
173 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 61
174 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 61
176 1. Introduction
178 The Hypertext Transfer Protocol (HTTP) is a stateless application-
179 level request/response protocol that uses extensible semantics and
180 self-descriptive messages for flexible interaction with network-based
181 hypertext information systems. HTTP is defined by a series of
182 documents that collectively form the HTTP/1.1 specification:
184 o "HTTP Semantics" [Semantics]
186 o "HTTP Caching" [Caching]
188 o "HTTP/1.1 Messaging" (this document)
190 This document defines HTTP/1.1 message syntax and framing
191 requirements and their associated connection management. Our goal is
192 to define all of the mechanisms necessary for HTTP/1.1 message
193 handling that are independent of message semantics, thereby defining
194 the complete set of requirements for message parsers and message-
195 forwarding intermediaries.
197 This document obsoletes the portions of RFC 7230 related to HTTP/1.1
198 messaging and connection management, with the changes being
199 summarized in Appendix C.2. The other parts of RFC 7230 are
200 obsoleted by "HTTP Semantics" [Semantics].
202 1.1. Requirements Notation
204 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
205 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
206 "OPTIONAL" in this document are to be interpreted as described in BCP
207 14 [RFC2119] [RFC8174] when, and only when, they appear in all
208 capitals, as shown here.
210 Conformance criteria and considerations regarding error handling are
211 defined in Section 3 of [Semantics].
213 1.2. Syntax Notation
215 This specification uses the Augmented Backus-Naur Form (ABNF)
216 notation of [RFC5234], extended with the notation for case-
217 sensitivity in strings defined in [RFC7405].
219 It also uses a list extension, defined in Section 5.5 of [Semantics],
220 that allows for compact definition of comma-separated lists using a
221 '#' operator (similar to how the '*' operator indicates repetition).
222 Appendix A shows the collected grammar with all list operators
223 expanded to standard ABNF notation.
225 As a convention, ABNF rule names prefixed with "obs-" denote
226 "obsolete" grammar rules that appear for historical reasons.
228 The following core rules are included by reference, as defined in
229 [RFC5234], Appendix B.1: ALPHA (letters), CR (carriage return), CRLF
230 (CR LF), CTL (controls), DIGIT (decimal 0-9), DQUOTE (double quote),
231 HEXDIG (hexadecimal 0-9/A-F/a-f), HTAB (horizontal tab), LF (line
232 feed), OCTET (any 8-bit sequence of data), SP (space), and VCHAR (any
233 visible [USASCII] character).
235 The rules below are defined in [Semantics]:
237 BWS =
238 OWS =
239 RWS =
240 absolute-URI =
241 absolute-path =
242 authority =
243 comment =
244 field-name =
245 field-value =
246 obs-text =
247 port =
248 query =
249 quoted-string =
250 token =
251 uri-host =
253 2. Message
255 2.1. Message Format
257 An HTTP/1.1 message consists of a start-line followed by a CRLF and a
258 sequence of octets in a format similar to the Internet Message Format
259 [RFC5322]: zero or more header field lines (collectively referred to
260 as the "headers" or the "header section"), an empty line indicating
261 the end of the header section, and an optional message body.
263 HTTP-message = start-line CRLF
264 *( field-line CRLF )
265 CRLF
266 [ message-body ]
268 A message can be either a request from client to server or a response
269 from server to client. Syntactically, the two types of message
270 differ only in the start-line, which is either a request-line (for
271 requests) or a status-line (for responses), and in the algorithm for
272 determining the length of the message body (Section 6).
274 start-line = request-line / status-line
276 In theory, a client could receive requests and a server could receive
277 responses, distinguishing them by their different start-line formats.
278 In practice, servers are implemented to only expect a request (a
279 response is interpreted as an unknown or invalid request method) and
280 clients are implemented to only expect a response.
282 Although HTTP makes use of some protocol elements similar to the
283 Multipurpose Internet Mail Extensions (MIME) [RFC2045], see
284 Appendix B for the differences between HTTP and MIME messages.
286 2.2. Message Parsing
288 The normal procedure for parsing an HTTP message is to read the
289 start-line into a structure, read each header field line into a hash
290 table by field name until the empty line, and then use the parsed
291 data to determine if a message body is expected. If a message body
292 has been indicated, then it is read as a stream until an amount of
293 octets equal to the message body length is read or the connection is
294 closed.
296 A recipient MUST parse an HTTP message as a sequence of octets in an
297 encoding that is a superset of US-ASCII [USASCII]. Parsing an HTTP
298 message as a stream of Unicode characters, without regard for the
299 specific encoding, creates security vulnerabilities due to the
300 varying ways that string processing libraries handle invalid
301 multibyte character sequences that contain the octet LF (%x0A).
302 String-based parsers can only be safely used within protocol elements
303 after the element has been extracted from the message, such as within
304 a header field line value after message parsing has delineated the
305 individual field lines.
307 Although the line terminator for the start-line and header fields is
308 the sequence CRLF, a recipient MAY recognize a single LF as a line
309 terminator and ignore any preceding CR.
311 A sender MUST NOT generate a bare CR (a CR character not immediately
312 followed by LF) within any protocol elements other than the payload
313 body. A recipient of such a bare CR MUST consider that element to be
314 invalid or replace each bare CR with SP before processing the element
315 or forwarding the message.
317 Older HTTP/1.0 user agent implementations might send an extra CRLF
318 after a POST request as a workaround for some early server
319 applications that failed to read message body content that was not
320 terminated by a line-ending. An HTTP/1.1 user agent MUST NOT preface
321 or follow a request with an extra CRLF. If terminating the request
322 message body with a line-ending is desired, then the user agent MUST
323 count the terminating CRLF octets as part of the message body length.
325 In the interest of robustness, a server that is expecting to receive
326 and parse a request-line SHOULD ignore at least one empty line (CRLF)
327 received prior to the request-line.
329 A sender MUST NOT send whitespace between the start-line and the
330 first header field. A recipient that receives whitespace between the
331 start-line and the first header field MUST either reject the message
332 as invalid or consume each whitespace-preceded line without further
333 processing of it (i.e., ignore the entire line, along with any
334 subsequent lines preceded by whitespace, until a properly formed
335 header field is received or the header section is terminated).
337 The presence of such whitespace in a request might be an attempt to
338 trick a server into ignoring that field line or processing the line
339 after it as a new request, either of which might result in a security
340 vulnerability if other implementations within the request chain
341 interpret the same message differently. Likewise, the presence of
342 such whitespace in a response might be ignored by some clients or
343 cause others to cease parsing.
345 When a server listening only for HTTP request messages, or processing
346 what appears from the start-line to be an HTTP request message,
347 receives a sequence of octets that does not match the HTTP-message
348 grammar aside from the robustness exceptions listed above, the server
349 SHOULD respond with a 400 (Bad Request) response.
351 2.3. HTTP Version
353 HTTP uses a "." numbering scheme to indicate versions
354 of the protocol. This specification defines version "1.1".
355 Section 4.2 of [Semantics] specifies the semantics of HTTP version
356 numbers.
358 The version of an HTTP/1.x message is indicated by an HTTP-version
359 field in the start-line. HTTP-version is case-sensitive.
361 HTTP-version = HTTP-name "/" DIGIT "." DIGIT
362 HTTP-name = %s"HTTP"
364 When an HTTP/1.1 message is sent to an HTTP/1.0 recipient [RFC1945]
365 or a recipient whose version is unknown, the HTTP/1.1 message is
366 constructed such that it can be interpreted as a valid HTTP/1.0
367 message if all of the newer features are ignored. This specification
368 places recipient-version requirements on some new features so that a
369 conformant sender will only use compatible features until it has
370 determined, through configuration or the receipt of a message, that
371 the recipient supports HTTP/1.1.
373 Intermediaries that process HTTP messages (i.e., all intermediaries
374 other than those acting as tunnels) MUST send their own HTTP-version
375 in forwarded messages. In other words, they are not allowed to
376 blindly forward the start-line without ensuring that the protocol
377 version in that message matches a version to which that intermediary
378 is conformant for both the receiving and sending of messages.
379 Forwarding an HTTP message without rewriting the HTTP-version might
380 result in communication errors when downstream recipients use the
381 message sender's version to determine what features are safe to use
382 for later communication with that sender.
384 A server MAY send an HTTP/1.0 response to an HTTP/1.1 request if it
385 is known or suspected that the client incorrectly implements the HTTP
386 specification and is incapable of correctly processing later version
387 responses, such as when a client fails to parse the version number
388 correctly or when an intermediary is known to blindly forward the
389 HTTP-version even when it doesn't conform to the given minor version
390 of the protocol. Such protocol downgrades SHOULD NOT be performed
391 unless triggered by specific client attributes, such as when one or
392 more of the request header fields (e.g., User-Agent) uniquely match
393 the values sent by a client known to be in error.
395 3. Request Line
397 A request-line begins with a method token, followed by a single space
398 (SP), the request-target, another single space (SP), and ends with
399 the protocol version.
401 request-line = method SP request-target SP HTTP-version
403 Although the request-line grammar rule requires that each of the
404 component elements be separated by a single SP octet, recipients MAY
405 instead parse on whitespace-delimited word boundaries and, aside from
406 the CRLF terminator, treat any form of whitespace as the SP separator
407 while ignoring preceding or trailing whitespace; such whitespace
408 includes one or more of the following octets: SP, HTAB, VT (%x0B), FF
409 (%x0C), or bare CR. However, lenient parsing can result in request
410 smuggling security vulnerabilities if there are multiple recipients
411 of the message and each has its own unique interpretation of
412 robustness (see Section 11.2).
414 HTTP does not place a predefined limit on the length of a request-
415 line, as described in Section 3 of [Semantics]. A server that
416 receives a method longer than any that it implements SHOULD respond
417 with a 501 (Not Implemented) status code. A server that receives a
418 request-target longer than any URI it wishes to parse MUST respond
419 with a 414 (URI Too Long) status code (see Section 10.5.15 of
420 [Semantics]).
422 Various ad hoc limitations on request-line length are found in
423 practice. It is RECOMMENDED that all HTTP senders and recipients
424 support, at a minimum, request-line lengths of 8000 octets.
426 3.1. Method
428 The method token indicates the request method to be performed on the
429 target resource. The request method is case-sensitive.
431 method = token
433 The request methods defined by this specification can be found in
434 Section 8 of [Semantics], along with information regarding the HTTP
435 method registry and considerations for defining new methods.
437 3.2. Request Target
439 The request-target identifies the target resource upon which to apply
440 the request. The client derives a request-target from its desired
441 target URI. There are four distinct formats for the request-target,
442 depending on both the method being requested and whether the request
443 is to a proxy.
445 request-target = origin-form
446 / absolute-form
447 / authority-form
448 / asterisk-form
450 No whitespace is allowed in the request-target. Unfortunately, some
451 user agents fail to properly encode or exclude whitespace found in
452 hypertext references, resulting in those disallowed characters being
453 sent as the request-target in a malformed request-line.
455 Recipients of an invalid request-line SHOULD respond with either a
456 400 (Bad Request) error or a 301 (Moved Permanently) redirect with
457 the request-target properly encoded. A recipient SHOULD NOT attempt
458 to autocorrect and then process the request without a redirect, since
459 the invalid request-line might be deliberately crafted to bypass
460 security filters along the request chain.
462 3.2.1. origin-form
464 The most common form of request-target is the origin-form.
466 origin-form = absolute-path [ "?" query ]
468 When making a request directly to an origin server, other than a
469 CONNECT or server-wide OPTIONS request (as detailed below), a client
470 MUST send only the absolute path and query components of the target
471 URI as the request-target. If the target URI's path component is
472 empty, the client MUST send "/" as the path within the origin-form of
473 request-target. A Host header field is also sent, as defined in
474 Section 6.6 of [Semantics].
476 For example, a client wishing to retrieve a representation of the
477 resource identified as
479 http://www.example.org/where?q=now
481 directly from the origin server would open (or reuse) a TCP
482 connection to port 80 of the host "www.example.org" and send the
483 lines:
485 GET /where?q=now HTTP/1.1
486 Host: www.example.org
488 followed by the remainder of the request message.
490 3.2.2. absolute-form
492 When making a request to a proxy, other than a CONNECT or server-wide
493 OPTIONS request (as detailed below), a client MUST send the target
494 URI in absolute-form as the request-target.
496 absolute-form = absolute-URI
498 The proxy is requested to either service that request from a valid
499 cache, if possible, or make the same request on the client's behalf
500 to either the next inbound proxy server or directly to the origin
501 server indicated by the request-target. Requirements on such
502 "forwarding" of messages are defined in Section 6.7 of [Semantics].
504 An example absolute-form of request-line would be:
506 GET http://www.example.org/pub/WWW/TheProject.html HTTP/1.1
508 A client MUST send a Host header field in an HTTP/1.1 request even if
509 the request-target is in the absolute-form, since this allows the
510 Host information to be forwarded through ancient HTTP/1.0 proxies
511 that might not have implemented Host.
513 When a proxy receives a request with an absolute-form of request-
514 target, the proxy MUST ignore the received Host header field (if any)
515 and instead replace it with the host information of the request-
516 target. A proxy that forwards such a request MUST generate a new
517 Host field value based on the received request-target rather than
518 forward the received Host field value.
520 When an origin server receives a request with an absolute-form of
521 request-target, the origin server MUST ignore the received Host
522 header field (if any) and instead use the host information of the
523 request-target. Note that if the request-target does not have an
524 authority component, an empty Host header field will be sent in this
525 case.
527 To allow for transition to the absolute-form for all requests in some
528 future version of HTTP, a server MUST accept the absolute-form in
529 requests, even though HTTP/1.1 clients will only send them in
530 requests to proxies.
532 3.2.3. authority-form
534 The authority-form of request-target is only used for CONNECT
535 requests (Section 8.3.6 of [Semantics]).
537 authority-form = authority
539 When making a CONNECT request to establish a tunnel through one or
540 more proxies, a client MUST send only the target URI's authority
541 component (excluding any userinfo and its "@" delimiter) as the
542 request-target. For example,
544 CONNECT www.example.com:80 HTTP/1.1
546 3.2.4. asterisk-form
548 The asterisk-form of request-target is only used for a server-wide
549 OPTIONS request (Section 8.3.7 of [Semantics]).
551 asterisk-form = "*"
553 When a client wishes to request OPTIONS for the server as a whole, as
554 opposed to a specific named resource of that server, the client MUST
555 send only "*" (%x2A) as the request-target. For example,
557 OPTIONS * HTTP/1.1
559 If a proxy receives an OPTIONS request with an absolute-form of
560 request-target in which the URI has an empty path and no query
561 component, then the last proxy on the request chain MUST send a
562 request-target of "*" when it forwards the request to the indicated
563 origin server.
565 For example, the request
567 OPTIONS http://www.example.org:8001 HTTP/1.1
569 would be forwarded by the final proxy as
571 OPTIONS * HTTP/1.1
572 Host: www.example.org:8001
574 after connecting to port 8001 of host "www.example.org".
576 3.3. Reconstructing the Target URI
578 Since the request-target often contains only part of the user agent's
579 target URI, a server constructs its value to properly service the
580 request (Section 6.1 of [Semantics]).
582 If the request-target is in absolute-form, the target URI is the same
583 as the request-target. Otherwise, the target URI is constructed as
584 follows:
586 If the server's configuration (or outbound gateway) provides a
587 fixed URI scheme, that scheme is used for the target URI.
588 Otherwise, if the request is received over a TLS-secured TCP
589 connection, the target URI's scheme is "https"; if not, the scheme
590 is "http".
592 If the server's configuration (or outbound gateway) provides a
593 fixed URI authority component, that authority is used for the
594 target URI. If not, then if the request-target is in authority-
595 form, the target URI's authority component is the same as the
596 request-target. If not, then if a Host header field is supplied
597 with a non-empty field-value, the authority component is the same
598 as the Host field-value. Otherwise, the authority component is
599 assigned the default name configured for the server and, if the
600 connection's incoming TCP port number differs from the default
601 port for the target URI's scheme, then a colon (":") and the
602 incoming port number (in decimal form) are appended to the
603 authority component.
605 If the request-target is in authority-form or asterisk-form, the
606 target URI's combined path and query component is empty.
607 Otherwise, the combined path and query component is the same as
608 the request-target.
610 The components of the target URI, once determined as above, can be
611 combined into absolute-URI form by concatenating the scheme,
612 "://", authority, and combined path and query component.
614 Example 1: the following message received over an insecure TCP
615 connection
616 GET /pub/WWW/TheProject.html HTTP/1.1
617 Host: www.example.org:8080
619 has a target URI of
621 http://www.example.org:8080/pub/WWW/TheProject.html
623 Example 2: the following message received over a TLS-secured TCP
624 connection
626 OPTIONS * HTTP/1.1
627 Host: www.example.org
629 has a target URI of
631 https://www.example.org
633 Recipients of an HTTP/1.0 request that lacks a Host header field
634 might need to use heuristics (e.g., examination of the URI path for
635 something unique to a particular host) in order to guess the target
636 URI's authority component.
638 4. Status Line
640 The first line of a response message is the status-line, consisting
641 of the protocol version, a space (SP), the status code, another
642 space, and ending with an OPTIONAL textual phrase describing the
643 status code.
645 status-line = HTTP-version SP status-code SP [reason-phrase]
647 Although the status-line grammar rule requires that each of the
648 component elements be separated by a single SP octet, recipients MAY
649 instead parse on whitespace-delimited word boundaries and, aside from
650 the line terminator, treat any form of whitespace as the SP separator
651 while ignoring preceding or trailing whitespace; such whitespace
652 includes one or more of the following octets: SP, HTAB, VT (%x0B), FF
653 (%x0C), or bare CR. However, lenient parsing can result in response
654 splitting security vulnerabilities if there are multiple recipients
655 of the message and each has its own unique interpretation of
656 robustness (see Section 11.1).
658 The status-code element is a 3-digit integer code describing the
659 result of the server's attempt to understand and satisfy the client's
660 corresponding request. The rest of the response message is to be
661 interpreted in light of the semantics defined for that status code.
662 See Section 10 of [Semantics] for information about the semantics of
663 status codes, including the classes of status code (indicated by the
664 first digit), the status codes defined by this specification,
665 considerations for the definition of new status codes, and the IANA
666 registry.
668 status-code = 3DIGIT
670 The reason-phrase element exists for the sole purpose of providing a
671 textual description associated with the numeric status code, mostly
672 out of deference to earlier Internet application protocols that were
673 more frequently used with interactive text clients.
675 reason-phrase = 1*( HTAB / SP / VCHAR / obs-text )
677 A client SHOULD ignore the reason-phrase content because it is not a
678 reliable channel for information (it might be translated for a given
679 locale, overwritten by intermediaries, or discarded when the message
680 is forwarded via other versions of HTTP). A server MUST send the
681 space that separates status-code from the reason-phrase even when the
682 reason-phrase is absent (i.e., the status-line would end with the
683 three octets SP CR LF).
685 5. Field Syntax
687 Each field line consists of a case-insensitive field name followed by
688 a colon (":"), optional leading whitespace, the field line value, and
689 optional trailing whitespace.
691 field-line = field-name ":" OWS field-value OWS
693 Most HTTP field names and the rules for parsing within field values
694 are defined in Section 5 of [Semantics]. This section covers the
695 generic syntax for header field inclusion within, and extraction
696 from, HTTP/1.1 messages. In addition, the following header fields
697 are defined by this document because they are specific to HTTP/1.1
698 message processing:
700 +-------------------+----------+---------------+
701 | Field Name | Status | Reference |
702 +-------------------+----------+---------------+
703 | Connection | standard | Section 9.1 |
704 | MIME-Version | standard | Appendix B.1 |
705 | TE | standard | Section 7.4 |
706 | Transfer-Encoding | standard | Section 6.1 |
707 | Upgrade | standard | Section 9.9 |
708 +-------------------+----------+---------------+
710 Table 1
712 Furthermore, the field name "Close" is reserved, since using that
713 name as an HTTP header field might conflict with the "close"
714 connection option of the Connection header field (Section 9.1).
716 +------------+----------+------------+-------------+
717 | Field Name | Status | Reference | Comments |
718 +------------+----------+------------+-------------+
719 | Close | standard | Section 5 | (reserved) |
720 +------------+----------+------------+-------------+
722 5.1. Field Line Parsing
724 Messages are parsed using a generic algorithm, independent of the
725 individual field names. The contents within a given field line value
726 are not parsed until a later stage of message interpretation (usually
727 after the message's entire header section has been processed).
729 No whitespace is allowed between the field name and colon. In the
730 past, differences in the handling of such whitespace have led to
731 security vulnerabilities in request routing and response handling. A
732 server MUST reject any received request message that contains
733 whitespace between a header field name and colon with a response
734 status code of 400 (Bad Request). A proxy MUST remove any such
735 whitespace from a response message before forwarding the message
736 downstream.
738 A field line value might be preceded and/or followed by optional
739 whitespace (OWS); a single SP preceding the field line value is
740 preferred for consistent readability by humans. The field line value
741 does not include any leading or trailing whitespace: OWS occurring
742 before the first non-whitespace octet of the field line value or
743 after the last non-whitespace octet of the field line value ought to
744 be excluded by parsers when extracting the field line value from a
745 header field line.
747 5.2. Obsolete Line Folding
749 Historically, HTTP header field line values could be extended over
750 multiple lines by preceding each extra line with at least one space
751 or horizontal tab (obs-fold). This specification deprecates such
752 line folding except within the message/http media type
753 (Section 10.1).
755 obs-fold = OWS CRLF RWS
756 ; obsolete line folding
758 A sender MUST NOT generate a message that includes line folding
759 (i.e., that has any field line value that contains a match to the
760 obs-fold rule) unless the message is intended for packaging within
761 the message/http media type.
763 A server that receives an obs-fold in a request message that is not
764 within a message/http container MUST either reject the message by
765 sending a 400 (Bad Request), preferably with a representation
766 explaining that obsolete line folding is unacceptable, or replace
767 each received obs-fold with one or more SP octets prior to
768 interpreting the field value or forwarding the message downstream.
770 A proxy or gateway that receives an obs-fold in a response message
771 that is not within a message/http container MUST either discard the
772 message and replace it with a 502 (Bad Gateway) response, preferably
773 with a representation explaining that unacceptable line folding was
774 received, or replace each received obs-fold with one or more SP
775 octets prior to interpreting the field value or forwarding the
776 message downstream.
778 A user agent that receives an obs-fold in a response message that is
779 not within a message/http container MUST replace each received obs-
780 fold with one or more SP octets prior to interpreting the field
781 value.
783 6. Message Body
785 The message body (if any) of an HTTP message is used to carry the
786 payload body (Section 7.3.3 of [Semantics]) of that request or
787 response. The message body is identical to the payload body unless a
788 transfer coding has been applied, as described in Section 6.1.
790 message-body = *OCTET
792 The rules for determining when a message body is present in an
793 HTTP/1.1 message differ for requests and responses.
795 The presence of a message body in a request is signaled by a Content-
796 Length or Transfer-Encoding header field. Request message framing is
797 independent of method semantics, even if the method does not define
798 any use for a message body.
800 The presence of a message body in a response depends on both the
801 request method to which it is responding and the response status code
802 (Section 4), and corresponds to when a payload body is allowed; see
803 Section 7.3.3 of [Semantics].
805 6.1. Transfer-Encoding
807 The Transfer-Encoding header field lists the transfer coding names
808 corresponding to the sequence of transfer codings that have been (or
809 will be) applied to the payload body in order to form the message
810 body. Transfer codings are defined in Section 7.
812 Transfer-Encoding = 1#transfer-coding
814 Transfer-Encoding is analogous to the Content-Transfer-Encoding field
815 of MIME, which was designed to enable safe transport of binary data
816 over a 7-bit transport service ([RFC2045], Section 6). However, safe
817 transport has a different focus for an 8bit-clean transfer protocol.
818 In HTTP's case, Transfer-Encoding is primarily intended to accurately
819 delimit a dynamically generated payload and to distinguish payload
820 encodings that are only applied for transport efficiency or security
821 from those that are characteristics of the selected resource.
823 A recipient MUST be able to parse the chunked transfer coding
824 (Section 7.1) because it plays a crucial role in framing messages
825 when the payload body size is not known in advance. A sender MUST
826 NOT apply chunked more than once to a message body (i.e., chunking an
827 already chunked message is not allowed). If any transfer coding
828 other than chunked is applied to a request payload body, the sender
829 MUST apply chunked as the final transfer coding to ensure that the
830 message is properly framed. If any transfer coding other than
831 chunked is applied to a response payload body, the sender MUST either
832 apply chunked as the final transfer coding or terminate the message
833 by closing the connection.
835 For example,
837 Transfer-Encoding: gzip, chunked
839 indicates that the payload body has been compressed using the gzip
840 coding and then chunked using the chunked coding while forming the
841 message body.
843 Unlike Content-Encoding (Section 7.1.2 of [Semantics]), Transfer-
844 Encoding is a property of the message, not of the representation, and
845 any recipient along the request/response chain MAY decode the
846 received transfer coding(s) or apply additional transfer coding(s) to
847 the message body, assuming that corresponding changes are made to the
848 Transfer-Encoding field value. Additional information about the
849 encoding parameters can be provided by other header fields not
850 defined by this specification.
852 Transfer-Encoding MAY be sent in a response to a HEAD request or in a
853 304 (Not Modified) response (Section 10.4.5 of [Semantics]) to a GET
854 request, neither of which includes a message body, to indicate that
855 the origin server would have applied a transfer coding to the message
856 body if the request had been an unconditional GET. This indication
857 is not required, however, because any recipient on the response chain
858 (including the origin server) can remove transfer codings when they
859 are not needed.
861 A server MUST NOT send a Transfer-Encoding header field in any
862 response with a status code of 1xx (Informational) or 204 (No
863 Content). A server MUST NOT send a Transfer-Encoding header field in
864 any 2xx (Successful) response to a CONNECT request (Section 8.3.6 of
865 [Semantics]).
867 Transfer-Encoding was added in HTTP/1.1. It is generally assumed
868 that implementations advertising only HTTP/1.0 support will not
869 understand how to process a transfer-encoded payload. A client MUST
870 NOT send a request containing Transfer-Encoding unless it knows the
871 server will handle HTTP/1.1 requests (or later minor revisions); such
872 knowledge might be in the form of specific user configuration or by
873 remembering the version of a prior received response. A server MUST
874 NOT send a response containing Transfer-Encoding unless the
875 corresponding request indicates HTTP/1.1 (or later minor revisions).
877 A server that receives a request message with a transfer coding it
878 does not understand SHOULD respond with 501 (Not Implemented).
880 6.2. Content-Length
882 When a message does not have a Transfer-Encoding header field, a
883 Content-Length header field can provide the anticipated size, as a
884 decimal number of octets, for a potential payload body. For messages
885 that do include a payload body, the Content-Length field value
886 provides the framing information necessary for determining where the
887 body (and message) ends. For messages that do not include a payload
888 body, the Content-Length indicates the size of the selected
889 representation (Section 7.2.4 of [Semantics]).
891 Note: HTTP's use of Content-Length for message framing differs
892 significantly from the same field's use in MIME, where it is an
893 optional field used only within the "message/external-body" media-
894 type.
896 6.3. Message Body Length
898 The length of a message body is determined by one of the following
899 (in order of precedence):
901 1. Any response to a HEAD request and any response with a 1xx
902 (Informational), 204 (No Content), or 304 (Not Modified) status
903 code is always terminated by the first empty line after the
904 header fields, regardless of the header fields present in the
905 message, and thus cannot contain a message body.
907 2. Any 2xx (Successful) response to a CONNECT request implies that
908 the connection will become a tunnel immediately after the empty
909 line that concludes the header fields. A client MUST ignore any
910 Content-Length or Transfer-Encoding header fields received in
911 such a message.
913 3. If a Transfer-Encoding header field is present and the chunked
914 transfer coding (Section 7.1) is the final encoding, the message
915 body length is determined by reading and decoding the chunked
916 data until the transfer coding indicates the data is complete.
918 If a Transfer-Encoding header field is present in a response and
919 the chunked transfer coding is not the final encoding, the
920 message body length is determined by reading the connection until
921 it is closed by the server. If a Transfer-Encoding header field
922 is present in a request and the chunked transfer coding is not
923 the final encoding, the message body length cannot be determined
924 reliably; the server MUST respond with the 400 (Bad Request)
925 status code and then close the connection.
927 If a message is received with both a Transfer-Encoding and a
928 Content-Length header field, the Transfer-Encoding overrides the
929 Content-Length. Such a message might indicate an attempt to
930 perform request smuggling (Section 11.2) or response splitting
931 (Section 11.1) and ought to be handled as an error. A sender
932 MUST remove the received Content-Length field prior to forwarding
933 such a message downstream.
935 4. If a message is received without Transfer-Encoding and with an
936 invalid Content-Length header field, then the message framing is
937 invalid and the recipient MUST treat it as an unrecoverable
938 error, unless the field value can be successfully parsed as a
939 comma-separated list (Section 5.5 of [Semantics]), all values in
940 the list are valid, and all values in the list are the same. If
941 this is a request message, the server MUST respond with a 400
942 (Bad Request) status code and then close the connection. If this
943 is a response message received by a proxy, the proxy MUST close
944 the connection to the server, discard the received response, and
945 send a 502 (Bad Gateway) response to the client. If this is a
946 response message received by a user agent, the user agent MUST
947 close the connection to the server and discard the received
948 response.
950 5. If a valid Content-Length header field is present without
951 Transfer-Encoding, its decimal value defines the expected message
952 body length in octets. If the sender closes the connection or
953 the recipient times out before the indicated number of octets are
954 received, the recipient MUST consider the message to be
955 incomplete and close the connection.
957 6. If this is a request message and none of the above are true, then
958 the message body length is zero (no message body is present).
960 7. Otherwise, this is a response message without a declared message
961 body length, so the message body length is determined by the
962 number of octets received prior to the server closing the
963 connection.
965 Since there is no way to distinguish a successfully completed, close-
966 delimited message from a partially received message interrupted by
967 network failure, a server SHOULD generate encoding or length-
968 delimited messages whenever possible. The close-delimiting feature
969 exists primarily for backwards compatibility with HTTP/1.0.
971 A server MAY reject a request that contains a message body but not a
972 Content-Length by responding with 411 (Length Required).
974 Unless a transfer coding other than chunked has been applied, a
975 client that sends a request containing a message body SHOULD use a
976 valid Content-Length header field if the message body length is known
977 in advance, rather than the chunked transfer coding, since some
978 existing services respond to chunked with a 411 (Length Required)
979 status code even though they understand the chunked transfer coding.
980 This is typically because such services are implemented via a gateway
981 that requires a content-length in advance of being called and the
982 server is unable or unwilling to buffer the entire request before
983 processing.
985 A user agent that sends a request containing a message body MUST send
986 a valid Content-Length header field if it does not know the server
987 will handle HTTP/1.1 (or later) requests; such knowledge can be in
988 the form of specific user configuration or by remembering the version
989 of a prior received response.
991 If the final response to the last request on a connection has been
992 completely received and there remains additional data to read, a user
993 agent MAY discard the remaining data or attempt to determine if that
994 data belongs as part of the prior response body, which might be the
995 case if the prior message's Content-Length value is incorrect. A
996 client MUST NOT process, cache, or forward such extra data as a
997 separate response, since such behavior would be vulnerable to cache
998 poisoning.
1000 7. Transfer Codings
1002 Transfer coding names are used to indicate an encoding transformation
1003 that has been, can be, or might need to be applied to a payload body
1004 in order to ensure "safe transport" through the network. This
1005 differs from a content coding in that the transfer coding is a
1006 property of the message rather than a property of the representation
1007 that is being transferred.
1009 transfer-coding = token *( OWS ";" OWS transfer-parameter )
1011 Parameters are in the form of a name=value pair.
1013 transfer-parameter = token BWS "=" BWS ( token / quoted-string )
1015 All transfer-coding names are case-insensitive and ought to be
1016 registered within the HTTP Transfer Coding registry, as defined in
1017 Section 7.3. They are used in the TE (Section 7.4) and Transfer-
1018 Encoding (Section 6.1) header fields.
1020 +------------+------------------------------------------+-----------+
1021 | Name | Description | Reference |
1022 +------------+------------------------------------------+-----------+
1023 | chunked | Transfer in a series of chunks | Section 7 |
1024 | | | .1 |
1025 | compress | UNIX "compress" data format [Welch] | Section 7 |
1026 | | | .2 |
1027 | deflate | "deflate" compressed data ([RFC1951]) | Section 7 |
1028 | | inside the "zlib" data format | .2 |
1029 | | ([RFC1950]) | |
1030 | gzip | GZIP file format [RFC1952] | Section 7 |
1031 | | | .2 |
1032 | trailers | (reserved) | Section 7 |
1033 | x-compress | Deprecated (alias for compress) | Section 7 |
1034 | | | .2 |
1035 | x-gzip | Deprecated (alias for gzip) | Section 7 |
1036 | | | .2 |
1037 +------------+------------------------------------------+-----------+
1039 Table 2
1041 Note: the coding name "trailers" is reserved because its use would
1042 conflict with the keyword "trailers" in the TE header field
1043 (Section 7.4).
1045 7.1. Chunked Transfer Coding
1047 The chunked transfer coding wraps the payload body in order to
1048 transfer it as a series of chunks, each with its own size indicator,
1049 followed by an OPTIONAL trailer section containing trailer fields.
1050 Chunked enables content streams of unknown size to be transferred as
1051 a sequence of length-delimited buffers, which enables the sender to
1052 retain connection persistence and the recipient to know when it has
1053 received the entire message.
1055 chunked-body = *chunk
1056 last-chunk
1057 trailer-section
1058 CRLF
1060 chunk = chunk-size [ chunk-ext ] CRLF
1061 chunk-data CRLF
1062 chunk-size = 1*HEXDIG
1063 last-chunk = 1*("0") [ chunk-ext ] CRLF
1065 chunk-data = 1*OCTET ; a sequence of chunk-size octets
1067 The chunk-size field is a string of hex digits indicating the size of
1068 the chunk-data in octets. The chunked transfer coding is complete
1069 when a chunk with a chunk-size of zero is received, possibly followed
1070 by a trailer section, and finally terminated by an empty line.
1072 A recipient MUST be able to parse and decode the chunked transfer
1073 coding.
1075 Note that HTTP/1.1 does not define any means to limit the size of a
1076 chunked response such that an intermediary can be assured of
1077 buffering the entire response.
1079 The chunked encoding does not define any parameters. Their presence
1080 SHOULD be treated as an error.
1082 7.1.1. Chunk Extensions
1084 The chunked encoding allows each chunk to include zero or more chunk
1085 extensions, immediately following the chunk-size, for the sake of
1086 supplying per-chunk metadata (such as a signature or hash), mid-
1087 message control information, or randomization of message body size.
1089 chunk-ext = *( BWS ";" BWS chunk-ext-name
1090 [ BWS "=" BWS chunk-ext-val ] )
1092 chunk-ext-name = token
1093 chunk-ext-val = token / quoted-string
1095 The chunked encoding is specific to each connection and is likely to
1096 be removed or recoded by each recipient (including intermediaries)
1097 before any higher-level application would have a chance to inspect
1098 the extensions. Hence, use of chunk extensions is generally limited
1099 to specialized HTTP services such as "long polling" (where client and
1100 server can have shared expectations regarding the use of chunk
1101 extensions) or for padding within an end-to-end secured connection.
1103 A recipient MUST ignore unrecognized chunk extensions. A server
1104 ought to limit the total length of chunk extensions received in a
1105 request to an amount reasonable for the services provided, in the
1106 same way that it applies length limitations and timeouts for other
1107 parts of a message, and generate an appropriate 4xx (Client Error)
1108 response if that amount is exceeded.
1110 7.1.2. Chunked Trailer Section
1112 A trailer section allows the sender to include additional fields at
1113 the end of a chunked message in order to supply metadata that might
1114 be dynamically generated while the message body is sent, such as a
1115 message integrity check, digital signature, or post-processing
1116 status. The proper use and limitations of trailer fields are defined
1117 in Section 5.6 of [Semantics].
1119 trailer-section = *( field-line CRLF )
1121 A recipient that decodes and removes the chunked encoding from a
1122 message (e.g., for storage or forwarding to a non-HTTP/1.1 peer) MUST
1123 discard any received trailer fields, store/forward them separately
1124 from the header fields, or selectively merge into the header section
1125 only those trailer fields corresponding to header field definitions
1126 that are understood by the recipient to explicitly permit and define
1127 how their corresponding trailer field value can be safely merged.
1129 7.1.3. Decoding Chunked
1131 A process for decoding the chunked transfer coding can be represented
1132 in pseudo-code as:
1134 length := 0
1135 read chunk-size, chunk-ext (if any), and CRLF
1136 while (chunk-size > 0) {
1137 read chunk-data and CRLF
1138 append chunk-data to decoded-body
1139 length := length + chunk-size
1140 read chunk-size, chunk-ext (if any), and CRLF
1141 }
1142 read trailer field
1143 while (trailer field is not empty) {
1144 if (trailer fields are stored/forwarded separately) {
1145 append trailer field to existing trailer fields
1146 }
1147 else if (trailer field is understood and defined as mergeable) {
1148 merge trailer field with existing header fields
1149 }
1150 else {
1151 discard trailer field
1152 }
1153 read trailer field
1154 }
1155 Content-Length := length
1156 Remove "chunked" from Transfer-Encoding
1157 Remove Trailer from existing header fields
1159 7.2. Transfer Codings for Compression
1161 The following transfer coding names for compression are defined by
1162 the same algorithm as their corresponding content coding:
1164 compress (and x-compress)
1165 See Section 7.1.2.1 of [Semantics].
1167 deflate
1168 See Section 7.1.2.2 of [Semantics].
1170 gzip (and x-gzip)
1171 See Section 7.1.2.3 of [Semantics].
1173 The compression codings do not define any parameters. Their presence
1174 SHOULD be treated as an error.
1176 7.3. Transfer Coding Registry
1178 The "HTTP Transfer Coding Registry" defines the namespace for
1179 transfer coding names. It is maintained at
1180 .
1182 Registrations MUST include the following fields:
1184 o Name
1186 o Description
1188 o Pointer to specification text
1190 Names of transfer codings MUST NOT overlap with names of content
1191 codings (Section 7.1.2 of [Semantics]) unless the encoding
1192 transformation is identical, as is the case for the compression
1193 codings defined in Section 7.2.
1195 The TE header field (Section 7.4) uses a pseudo parameter named "q"
1196 as rank value when multiple transfer codings are acceptable. Future
1197 registrations of transfer codings SHOULD NOT define parameters called
1198 "q" (case-insensitively) in order to avoid ambiguities.
1200 Values to be added to this namespace require IETF Review (see
1201 Section 4.8 of [RFC8126]), and MUST conform to the purpose of
1202 transfer coding defined in this specification.
1204 Use of program names for the identification of encoding formats is
1205 not desirable and is discouraged for future encodings.
1207 7.4. TE
1209 The "TE" header field in a request indicates what transfer codings,
1210 besides chunked, the client is willing to accept in response, and
1211 whether or not the client is willing to accept trailer fields in a
1212 chunked transfer coding.
1214 The TE field-value consists of a list of transfer coding names, each
1215 allowing for optional parameters (as described in Section 7), and/or
1216 the keyword "trailers". A client MUST NOT send the chunked transfer
1217 coding name in TE; chunked is always acceptable for HTTP/1.1
1218 recipients.
1220 TE = #t-codings
1221 t-codings = "trailers" / ( transfer-coding [ t-ranking ] )
1222 t-ranking = OWS ";" OWS "q=" rank
1223 rank = ( "0" [ "." 0*3DIGIT ] )
1224 / ( "1" [ "." 0*3("0") ] )
1226 Three examples of TE use are below.
1228 TE: deflate
1229 TE:
1230 TE: trailers, deflate;q=0.5
1232 When multiple transfer codings are acceptable, the client MAY rank
1233 the codings by preference using a case-insensitive "q" parameter
1234 (similar to the qvalues used in content negotiation fields,
1235 Section 7.4.4 of [Semantics]). The rank value is a real number in
1236 the range 0 through 1, where 0.001 is the least preferred and 1 is
1237 the most preferred; a value of 0 means "not acceptable".
1239 If the TE field value is empty or if no TE field is present, the only
1240 acceptable transfer coding is chunked. A message with no transfer
1241 coding is always acceptable.
1243 The keyword "trailers" indicates that the sender will not discard
1244 trailer fields, as described in Section 5.6 of [Semantics].
1246 Since the TE header field only applies to the immediate connection, a
1247 sender of TE MUST also send a "TE" connection option within the
1248 Connection header field (Section 9.1) in order to prevent the TE
1249 field from being forwarded by intermediaries that do not support its
1250 semantics.
1252 8. Handling Incomplete Messages
1254 A server that receives an incomplete request message, usually due to
1255 a canceled request or a triggered timeout exception, MAY send an
1256 error response prior to closing the connection.
1258 A client that receives an incomplete response message, which can
1259 occur when a connection is closed prematurely or when decoding a
1260 supposedly chunked transfer coding fails, MUST record the message as
1261 incomplete. Cache requirements for incomplete responses are defined
1262 in Section 3 of [Caching].
1264 If a response terminates in the middle of the header section (before
1265 the empty line is received) and the status code might rely on header
1266 fields to convey the full meaning of the response, then the client
1267 cannot assume that meaning has been conveyed; the client might need
1268 to repeat the request in order to determine what action to take next.
1270 A message body that uses the chunked transfer coding is incomplete if
1271 the zero-sized chunk that terminates the encoding has not been
1272 received. A message that uses a valid Content-Length is incomplete
1273 if the size of the message body received (in octets) is less than the
1274 value given by Content-Length. A response that has neither chunked
1275 transfer coding nor Content-Length is terminated by closure of the
1276 connection and, thus, is considered complete regardless of the number
1277 of message body octets received, provided that the header section was
1278 received intact.
1280 9. Connection Management
1282 HTTP messaging is independent of the underlying transport- or
1283 session-layer connection protocol(s). HTTP only presumes a reliable
1284 transport with in-order delivery of requests and the corresponding
1285 in-order delivery of responses. The mapping of HTTP request and
1286 response structures onto the data units of an underlying transport
1287 protocol is outside the scope of this specification.
1289 As described in Section 6.3 of [Semantics], the specific connection
1290 protocols to be used for an HTTP interaction are determined by client
1291 configuration and the target URI. For example, the "http" URI scheme
1292 (Section 2.5.1 of [Semantics]) indicates a default connection of TCP
1293 over IP, with a default TCP port of 80, but the client might be
1294 configured to use a proxy via some other connection, port, or
1295 protocol.
1297 HTTP implementations are expected to engage in connection management,
1298 which includes maintaining the state of current connections,
1299 establishing a new connection or reusing an existing connection,
1300 processing messages received on a connection, detecting connection
1301 failures, and closing each connection. Most clients maintain
1302 multiple connections in parallel, including more than one connection
1303 per server endpoint. Most servers are designed to maintain thousands
1304 of concurrent connections, while controlling request queues to enable
1305 fair use and detect denial-of-service attacks.
1307 9.1. Connection
1309 The "Connection" header field allows the sender to list desired
1310 control options for the current connection.
1312 When a field aside from Connection is used to supply control
1313 information for or about the current connection, the sender MUST list
1314 the corresponding field name within the Connection header field.
1316 Intermediaries MUST parse a received Connection header field before a
1317 message is forwarded and, for each connection-option in this field,
1318 remove any header or trailer field(s) from the message with the same
1319 name as the connection-option, and then remove the Connection header
1320 field itself (or replace it with the intermediary's own connection
1321 options for the forwarded message).
1323 Hence, the Connection header field provides a declarative way of
1324 distinguishing fields that are only intended for the immediate
1325 recipient ("hop-by-hop") from those fields that are intended for all
1326 recipients on the chain ("end-to-end"), enabling the message to be
1327 self-descriptive and allowing future connection-specific extensions
1328 to be deployed without fear that they will be blindly forwarded by
1329 older intermediaries.
1331 Furthermore, intermediaries SHOULD remove or replace field(s) whose
1332 semantics are known to require removal before forwarding, whether or
1333 not they appear as a Connection option, after applying those fields'
1334 semantics. This includes but is not limited to:
1336 o Proxy-Connection (Appendix C.1.2)
1338 o Keep-Alive (Section 19.7.1 of [RFC2068])
1340 o TE (Section 7.4)
1342 o Trailer (Section 5.6.3 of [Semantics])
1344 o Transfer-Encoding (Section 6.1)
1346 o Upgrade (Section 9.9)
1347 The Connection header field's value has the following grammar:
1349 Connection = 1#connection-option
1350 connection-option = token
1352 Connection options are case-insensitive.
1354 A sender MUST NOT send a connection option corresponding to a field
1355 that is intended for all recipients of the payload. For example,
1356 Cache-Control is never appropriate as a connection option
1357 (Section 5.2 of [Caching]).
1359 The connection options do not always correspond to a field present in
1360 the message, since a connection-specific field might not be needed if
1361 there are no parameters associated with a connection option. In
1362 contrast, a connection-specific field that is received without a
1363 corresponding connection option usually indicates that the field has
1364 been improperly forwarded by an intermediary and ought to be ignored
1365 by the recipient.
1367 When defining new connection options, specification authors ought to
1368 document it as reserved field name and register that definition in
1369 the Hypertext Transfer Protocol (HTTP) Field Name Registry
1370 (Section 5.3.2 of [Semantics]), to avoid collisions.
1372 The "close" connection option is defined for a sender to signal that
1373 this connection will be closed after completion of the response. For
1374 example,
1376 Connection: close
1378 in either the request or the response header fields indicates that
1379 the sender is going to close the connection after the current
1380 request/response is complete (Section 9.7).
1382 A client that does not support persistent connections MUST send the
1383 "close" connection option in every request message.
1385 A server that does not support persistent connections MUST send the
1386 "close" connection option in every response message that does not
1387 have a 1xx (Informational) status code.
1389 9.2. Establishment
1391 It is beyond the scope of this specification to describe how
1392 connections are established via various transport- or session-layer
1393 protocols. Each connection applies to only one transport link.
1395 9.3. Associating a Response to a Request
1397 HTTP/1.1 does not include a request identifier for associating a
1398 given request message with its corresponding one or more response
1399 messages. Hence, it relies on the order of response arrival to
1400 correspond exactly to the order in which requests are made on the
1401 same connection. More than one response message per request only
1402 occurs when one or more informational responses (1xx, see
1403 Section 10.2 of [Semantics]) precede a final response to the same
1404 request.
1406 A client that has more than one outstanding request on a connection
1407 MUST maintain a list of outstanding requests in the order sent and
1408 MUST associate each received response message on that connection to
1409 the highest ordered request that has not yet received a final (non-
1410 1xx) response.
1412 If an HTTP/1.1 client receives data on a connection that doesn't have
1413 any outstanding requests, it MUST NOT consider them to be a response
1414 to a not-yet-issued request; it SHOULD close the connection, since
1415 message delimitation is now ambiguous, unless the data consists only
1416 of one or more CRLF (which can be discarded, as per Section 2.2).
1418 9.4. Persistence
1420 HTTP/1.1 defaults to the use of "persistent connections", allowing
1421 multiple requests and responses to be carried over a single
1422 connection. The "close" connection option is used to signal that a
1423 connection will not persist after the current request/response. HTTP
1424 implementations SHOULD support persistent connections.
1426 A recipient determines whether a connection is persistent or not
1427 based on the most recently received message's protocol version and
1428 Connection header field (if any):
1430 o If the "close" connection option is present, the connection will
1431 not persist after the current response; else,
1433 o If the received protocol is HTTP/1.1 (or later), the connection
1434 will persist after the current response; else,
1436 o If the received protocol is HTTP/1.0, the "keep-alive" connection
1437 option is present, either the recipient is not a proxy or the
1438 message is a response, and the recipient wishes to honor the
1439 HTTP/1.0 "keep-alive" mechanism, the connection will persist after
1440 the current response; otherwise,
1442 o The connection will close after the current response.
1444 A client MAY send additional requests on a persistent connection
1445 until it sends or receives a "close" connection option or receives an
1446 HTTP/1.0 response without a "keep-alive" connection option.
1448 In order to remain persistent, all messages on a connection need to
1449 have a self-defined message length (i.e., one not defined by closure
1450 of the connection), as described in Section 6. A server MUST read
1451 the entire request message body or close the connection after sending
1452 its response, since otherwise the remaining data on a persistent
1453 connection would be misinterpreted as the next request. Likewise, a
1454 client MUST read the entire response message body if it intends to
1455 reuse the same connection for a subsequent request.
1457 A proxy server MUST NOT maintain a persistent connection with an
1458 HTTP/1.0 client (see Section 19.7.1 of [RFC2068] for information and
1459 discussion of the problems with the Keep-Alive header field
1460 implemented by many HTTP/1.0 clients).
1462 See Appendix C.1.2 for more information on backwards compatibility
1463 with HTTP/1.0 clients.
1465 9.4.1. Retrying Requests
1467 Connections can be closed at any time, with or without intention.
1468 Implementations ought to anticipate the need to recover from
1469 asynchronous close events. The conditions under which a client can
1470 automatically retry a sequence of outstanding requests are defined in
1471 Section 8.2.2 of [Semantics].
1473 9.4.2. Pipelining
1475 A client that supports persistent connections MAY "pipeline" its
1476 requests (i.e., send multiple requests without waiting for each
1477 response). A server MAY process a sequence of pipelined requests in
1478 parallel if they all have safe methods (Section 8.2.1 of
1479 [Semantics]), but it MUST send the corresponding responses in the
1480 same order that the requests were received.
1482 A client that pipelines requests SHOULD retry unanswered requests if
1483 the connection closes before it receives all of the corresponding
1484 responses. When retrying pipelined requests after a failed
1485 connection (a connection not explicitly closed by the server in its
1486 last complete response), a client MUST NOT pipeline immediately after
1487 connection establishment, since the first remaining request in the
1488 prior pipeline might have caused an error response that can be lost
1489 again if multiple requests are sent on a prematurely closed
1490 connection (see the TCP reset problem described in Section 9.7).
1492 Idempotent methods (Section 8.2.2 of [Semantics]) are significant to
1493 pipelining because they can be automatically retried after a
1494 connection failure. A user agent SHOULD NOT pipeline requests after
1495 a non-idempotent method, until the final response status code for
1496 that method has been received, unless the user agent has a means to
1497 detect and recover from partial failure conditions involving the
1498 pipelined sequence.
1500 An intermediary that receives pipelined requests MAY pipeline those
1501 requests when forwarding them inbound, since it can rely on the
1502 outbound user agent(s) to determine what requests can be safely
1503 pipelined. If the inbound connection fails before receiving a
1504 response, the pipelining intermediary MAY attempt to retry a sequence
1505 of requests that have yet to receive a response if the requests all
1506 have idempotent methods; otherwise, the pipelining intermediary
1507 SHOULD forward any received responses and then close the
1508 corresponding outbound connection(s) so that the outbound user
1509 agent(s) can recover accordingly.
1511 9.5. Concurrency
1513 A client ought to limit the number of simultaneous open connections
1514 that it maintains to a given server.
1516 Previous revisions of HTTP gave a specific number of connections as a
1517 ceiling, but this was found to be impractical for many applications.
1518 As a result, this specification does not mandate a particular maximum
1519 number of connections but, instead, encourages clients to be
1520 conservative when opening multiple connections.
1522 Multiple connections are typically used to avoid the "head-of-line
1523 blocking" problem, wherein a request that takes significant server-
1524 side processing and/or has a large payload blocks subsequent requests
1525 on the same connection. However, each connection consumes server
1526 resources. Furthermore, using multiple connections can cause
1527 undesirable side effects in congested networks.
1529 Note that a server might reject traffic that it deems abusive or
1530 characteristic of a denial-of-service attack, such as an excessive
1531 number of open connections from a single client.
1533 9.6. Failures and Timeouts
1535 Servers will usually have some timeout value beyond which they will
1536 no longer maintain an inactive connection. Proxy servers might make
1537 this a higher value since it is likely that the client will be making
1538 more connections through the same proxy server. The use of
1539 persistent connections places no requirements on the length (or
1540 existence) of this timeout for either the client or the server.
1542 A client or server that wishes to time out SHOULD issue a graceful
1543 close on the connection. Implementations SHOULD constantly monitor
1544 open connections for a received closure signal and respond to it as
1545 appropriate, since prompt closure of both sides of a connection
1546 enables allocated system resources to be reclaimed.
1548 A client, server, or proxy MAY close the transport connection at any
1549 time. For example, a client might have started to send a new request
1550 at the same time that the server has decided to close the "idle"
1551 connection. From the server's point of view, the connection is being
1552 closed while it was idle, but from the client's point of view, a
1553 request is in progress.
1555 A server SHOULD sustain persistent connections, when possible, and
1556 allow the underlying transport's flow-control mechanisms to resolve
1557 temporary overloads, rather than terminate connections with the
1558 expectation that clients will retry. The latter technique can
1559 exacerbate network congestion.
1561 A client sending a message body SHOULD monitor the network connection
1562 for an error response while it is transmitting the request. If the
1563 client sees a response that indicates the server does not wish to
1564 receive the message body and is closing the connection, the client
1565 SHOULD immediately cease transmitting the body and close its side of
1566 the connection.
1568 9.7. Tear-down
1570 The Connection header field (Section 9.1) provides a "close"
1571 connection option that a sender SHOULD send when it wishes to close
1572 the connection after the current request/response pair.
1574 A client that sends a "close" connection option MUST NOT send further
1575 requests on that connection (after the one containing "close") and
1576 MUST close the connection after reading the final response message
1577 corresponding to this request.
1579 A server that receives a "close" connection option MUST initiate a
1580 close of the connection (see below) after it sends the final response
1581 to the request that contained "close". The server SHOULD send a
1582 "close" connection option in its final response on that connection.
1583 The server MUST NOT process any further requests received on that
1584 connection.
1586 A server that sends a "close" connection option MUST initiate a close
1587 of the connection (see below) after it sends the response containing
1588 "close". The server MUST NOT process any further requests received
1589 on that connection.
1591 A client that receives a "close" connection option MUST cease sending
1592 requests on that connection and close the connection after reading
1593 the response message containing the "close"; if additional pipelined
1594 requests had been sent on the connection, the client SHOULD NOT
1595 assume that they will be processed by the server.
1597 If a server performs an immediate close of a TCP connection, there is
1598 a significant risk that the client will not be able to read the last
1599 HTTP response. If the server receives additional data from the
1600 client on a fully closed connection, such as another request that was
1601 sent by the client before receiving the server's response, the
1602 server's TCP stack will send a reset packet to the client;
1603 unfortunately, the reset packet might erase the client's
1604 unacknowledged input buffers before they can be read and interpreted
1605 by the client's HTTP parser.
1607 To avoid the TCP reset problem, servers typically close a connection
1608 in stages. First, the server performs a half-close by closing only
1609 the write side of the read/write connection. The server then
1610 continues to read from the connection until it receives a
1611 corresponding close by the client, or until the server is reasonably
1612 certain that its own TCP stack has received the client's
1613 acknowledgement of the packet(s) containing the server's last
1614 response. Finally, the server fully closes the connection.
1616 It is unknown whether the reset problem is exclusive to TCP or might
1617 also be found in other transport connection protocols.
1619 9.8. TLS Connection Closure
1621 TLS provides a facility for secure connection closure. When a valid
1622 closure alert is received, an implementation can be assured that no
1623 further data will be received on that connection. TLS
1624 implementations MUST initiate an exchange of closure alerts before
1625 closing a connection. A TLS implementation MAY, after sending a
1626 closure alert, close the connection without waiting for the peer to
1627 send its closure alert, generating an "incomplete close". Note that
1628 an implementation which does this MAY choose to reuse the session.
1629 This SHOULD only be done when the application knows (typically
1630 through detecting HTTP message boundaries) that it has received all
1631 the message data that it cares about.
1633 As specified in [RFC8446], any implementation which receives a
1634 connection close without first receiving a valid closure alert (a
1635 "premature close") MUST NOT reuse that session. Note that a
1636 premature close does not call into question the security of the data
1637 already received, but simply indicates that subsequent data might
1638 have been truncated. Because TLS is oblivious to HTTP request/
1639 response boundaries, it is necessary to examine the HTTP data itself
1640 (specifically the Content-Length header) to determine whether the
1641 truncation occurred inside a message or between messages.
1643 When encountering a premature close, a client SHOULD treat as
1644 completed all requests for which it has received as much data as
1645 specified in the Content-Length header.
1647 A client detecting an incomplete close SHOULD recover gracefully. It
1648 MAY resume a TLS session closed in this fashion.
1650 Clients MUST send a closure alert before closing the connection.
1651 Clients which are unprepared to receive any more data MAY choose not
1652 to wait for the server's closure alert and simply close the
1653 connection, thus generating an incomplete close on the server side.
1655 Servers SHOULD be prepared to receive an incomplete close from the
1656 client, since the client can often determine when the end of server
1657 data is. Servers SHOULD be willing to resume TLS sessions closed in
1658 this fashion.
1660 Servers MUST attempt to initiate an exchange of closure alerts with
1661 the client before closing the connection. Servers MAY close the
1662 connection after sending the closure alert, thus generating an
1663 incomplete close on the client side.
1665 9.9. Upgrade
1667 The "Upgrade" header field is intended to provide a simple mechanism
1668 for transitioning from HTTP/1.1 to some other protocol on the same
1669 connection.
1671 A client MAY send a list of protocol names in the Upgrade header
1672 field of a request to invite the server to switch to one or more of
1673 the named protocols, in order of descending preference, before
1674 sending the final response. A server MAY ignore a received Upgrade
1675 header field if it wishes to continue using the current protocol on
1676 that connection. Upgrade cannot be used to insist on a protocol
1677 change.
1679 Upgrade = 1#protocol
1681 protocol = protocol-name ["/" protocol-version]
1682 protocol-name = token
1683 protocol-version = token
1685 Although protocol names are registered with a preferred case,
1686 recipients SHOULD use case-insensitive comparison when matching each
1687 protocol-name to supported protocols.
1689 A server that sends a 101 (Switching Protocols) response MUST send an
1690 Upgrade header field to indicate the new protocol(s) to which the
1691 connection is being switched; if multiple protocol layers are being
1692 switched, the sender MUST list the protocols in layer-ascending
1693 order. A server MUST NOT switch to a protocol that was not indicated
1694 by the client in the corresponding request's Upgrade header field. A
1695 server MAY choose to ignore the order of preference indicated by the
1696 client and select the new protocol(s) based on other factors, such as
1697 the nature of the request or the current load on the server.
1699 A server that sends a 426 (Upgrade Required) response MUST send an
1700 Upgrade header field to indicate the acceptable protocols, in order
1701 of descending preference.
1703 A server MAY send an Upgrade header field in any other response to
1704 advertise that it implements support for upgrading to the listed
1705 protocols, in order of descending preference, when appropriate for a
1706 future request.
1708 The following is a hypothetical example sent by a client:
1710 GET /hello HTTP/1.1
1711 Host: www.example.com
1712 Connection: upgrade
1713 Upgrade: websocket, IRC/6.9, RTA/x11
1715 The capabilities and nature of the application-level communication
1716 after the protocol change is entirely dependent upon the new
1717 protocol(s) chosen. However, immediately after sending the 101
1718 (Switching Protocols) response, the server is expected to continue
1719 responding to the original request as if it had received its
1720 equivalent within the new protocol (i.e., the server still has an
1721 outstanding request to satisfy after the protocol has been changed,
1722 and is expected to do so without requiring the request to be
1723 repeated).
1725 For example, if the Upgrade header field is received in a GET request
1726 and the server decides to switch protocols, it first responds with a
1727 101 (Switching Protocols) message in HTTP/1.1 and then immediately
1728 follows that with the new protocol's equivalent of a response to a
1729 GET on the target resource. This allows a connection to be upgraded
1730 to protocols with the same semantics as HTTP without the latency cost
1731 of an additional round trip. A server MUST NOT switch protocols
1732 unless the received message semantics can be honored by the new
1733 protocol; an OPTIONS request can be honored by any protocol.
1735 The following is an example response to the above hypothetical
1736 request:
1738 HTTP/1.1 101 Switching Protocols
1739 Connection: upgrade
1740 Upgrade: websocket
1742 [... data stream switches to websocket with an appropriate response
1743 (as defined by new protocol) to the "GET /hello" request ...]
1745 When Upgrade is sent, the sender MUST also send a Connection header
1746 field (Section 9.1) that contains an "upgrade" connection option, in
1747 order to prevent Upgrade from being accidentally forwarded by
1748 intermediaries that might not implement the listed protocols. A
1749 server MUST ignore an Upgrade header field that is received in an
1750 HTTP/1.0 request.
1752 A client cannot begin using an upgraded protocol on the connection
1753 until it has completely sent the request message (i.e., the client
1754 can't change the protocol it is sending in the middle of a message).
1755 If a server receives both an Upgrade and an Expect header field with
1756 the "100-continue" expectation (Section 9.1.1 of [Semantics]), the
1757 server MUST send a 100 (Continue) response before sending a 101
1758 (Switching Protocols) response.
1760 The Upgrade header field only applies to switching protocols on top
1761 of the existing connection; it cannot be used to switch the
1762 underlying connection (transport) protocol, nor to switch the
1763 existing communication to a different connection. For those
1764 purposes, it is more appropriate to use a 3xx (Redirection) response
1765 (Section 10.4 of [Semantics]).
1767 9.9.1. Upgrade Protocol Names
1769 This specification only defines the protocol name "HTTP" for use by
1770 the family of Hypertext Transfer Protocols, as defined by the HTTP
1771 version rules of Section 4.2 of [Semantics] and future updates to
1772 this specification. Additional protocol names ought to be registered
1773 using the registration procedure defined in Section 9.9.2.
1775 +------+-------------------+--------------------+-------------------+
1776 | Name | Description | Expected Version | Reference |
1777 | | | Tokens | |
1778 +------+-------------------+--------------------+-------------------+
1779 | HTTP | Hypertext | any DIGIT.DIGIT | Section 4.2 of |
1780 | | Transfer Protocol | (e.g, "2.0") | [Semantics] |
1781 +------+-------------------+--------------------+-------------------+
1783 9.9.2. Upgrade Token Registry
1785 The "Hypertext Transfer Protocol (HTTP) Upgrade Token Registry"
1786 defines the namespace for protocol-name tokens used to identify
1787 protocols in the Upgrade header field. The registry is maintained at
1788 .
1790 Each registered protocol name is associated with contact information
1791 and an optional set of specifications that details how the connection
1792 will be processed after it has been upgraded.
1794 Registrations happen on a "First Come First Served" basis (see
1795 Section 4.4 of [RFC8126]) and are subject to the following rules:
1797 1. A protocol-name token, once registered, stays registered forever.
1799 2. A protocol-name token is case-insensitive and registered with the
1800 preferred case to be generated by senders.
1802 3. The registration MUST name a responsible party for the
1803 registration.
1805 4. The registration MUST name a point of contact.
1807 5. The registration MAY name a set of specifications associated with
1808 that token. Such specifications need not be publicly available.
1810 6. The registration SHOULD name a set of expected "protocol-version"
1811 tokens associated with that token at the time of registration.
1813 7. The responsible party MAY change the registration at any time.
1814 The IANA will keep a record of all such changes, and make them
1815 available upon request.
1817 8. The IESG MAY reassign responsibility for a protocol token. This
1818 will normally only be used in the case when a responsible party
1819 cannot be contacted.
1821 10. Enclosing Messages as Data
1823 10.1. Media Type message/http
1825 The message/http media type can be used to enclose a single HTTP
1826 request or response message, provided that it obeys the MIME
1827 restrictions for all "message" types regarding line length and
1828 encodings.
1830 Type name: message
1832 Subtype name: http
1834 Required parameters: N/A
1836 Optional parameters: version, msgtype
1838 version: The HTTP-version number of the enclosed message (e.g.,
1839 "1.1"). If not present, the version can be determined from the
1840 first line of the body.
1842 msgtype: The message type -- "request" or "response". If not
1843 present, the type can be determined from the first line of the
1844 body.
1846 Encoding considerations: only "7bit", "8bit", or "binary" are
1847 permitted
1849 Security considerations: see Section 11
1851 Interoperability considerations: N/A
1853 Published specification: This specification (see Section 10.1).
1855 Applications that use this media type: N/A
1857 Fragment identifier considerations: N/A
1859 Additional information:
1861 Magic number(s): N/A
1863 Deprecated alias names for this type: N/A
1865 File extension(s): N/A
1866 Macintosh file type code(s): N/A
1868 Person and email address to contact for further information:
1869 See Authors' Addresses section.
1871 Intended usage: COMMON
1873 Restrictions on usage: N/A
1875 Author: See Authors' Addresses section.
1877 Change controller: IESG
1879 10.2. Media Type application/http
1881 The application/http media type can be used to enclose a pipeline of
1882 one or more HTTP request or response messages (not intermixed).
1884 Type name: application
1886 Subtype name: http
1888 Required parameters: N/A
1890 Optional parameters: version, msgtype
1892 version: The HTTP-version number of the enclosed messages (e.g.,
1893 "1.1"). If not present, the version can be determined from the
1894 first line of the body.
1896 msgtype: The message type -- "request" or "response". If not
1897 present, the type can be determined from the first line of the
1898 body.
1900 Encoding considerations: HTTP messages enclosed by this type are in
1901 "binary" format; use of an appropriate Content-Transfer-Encoding
1902 is required when transmitted via email.
1904 Security considerations: see Section 11
1906 Interoperability considerations: N/A
1908 Published specification: This specification (see Section 10.2).
1910 Applications that use this media type: N/A
1911 Fragment identifier considerations: N/A
1913 Additional information:
1915 Deprecated alias names for this type: N/A
1917 Magic number(s): N/A
1919 File extension(s): N/A
1921 Macintosh file type code(s): N/A
1923 Person and email address to contact for further information:
1924 See Authors' Addresses section.
1926 Intended usage: COMMON
1928 Restrictions on usage: N/A
1930 Author: See Authors' Addresses section.
1932 Change controller: IESG
1934 11. Security Considerations
1936 This section is meant to inform developers, information providers,
1937 and users of known security considerations relevant to HTTP message
1938 syntax, parsing, and routing. Security considerations about HTTP
1939 semantics and payloads are addressed in [Semantics].
1941 11.1. Response Splitting
1943 Response splitting (a.k.a, CRLF injection) is a common technique,
1944 used in various attacks on Web usage, that exploits the line-based
1945 nature of HTTP message framing and the ordered association of
1946 requests to responses on persistent connections [Klein]. This
1947 technique can be particularly damaging when the requests pass through
1948 a shared cache.
1950 Response splitting exploits a vulnerability in servers (usually
1951 within an application server) where an attacker can send encoded data
1952 within some parameter of the request that is later decoded and echoed
1953 within any of the response header fields of the response. If the
1954 decoded data is crafted to look like the response has ended and a
1955 subsequent response has begun, the response has been split and the
1956 content within the apparent second response is controlled by the
1957 attacker. The attacker can then make any other request on the same
1958 persistent connection and trick the recipients (including
1959 intermediaries) into believing that the second half of the split is
1960 an authoritative answer to the second request.
1962 For example, a parameter within the request-target might be read by
1963 an application server and reused within a redirect, resulting in the
1964 same parameter being echoed in the Location header field of the
1965 response. If the parameter is decoded by the application and not
1966 properly encoded when placed in the response field, the attacker can
1967 send encoded CRLF octets and other content that will make the
1968 application's single response look like two or more responses.
1970 A common defense against response splitting is to filter requests for
1971 data that looks like encoded CR and LF (e.g., "%0D" and "%0A").
1972 However, that assumes the application server is only performing URI
1973 decoding, rather than more obscure data transformations like charset
1974 transcoding, XML entity translation, base64 decoding, sprintf
1975 reformatting, etc. A more effective mitigation is to prevent
1976 anything other than the server's core protocol libraries from sending
1977 a CR or LF within the header section, which means restricting the
1978 output of header fields to APIs that filter for bad octets and not
1979 allowing application servers to write directly to the protocol
1980 stream.
1982 11.2. Request Smuggling
1984 Request smuggling ([Linhart]) is a technique that exploits
1985 differences in protocol parsing among various recipients to hide
1986 additional requests (which might otherwise be blocked or disabled by
1987 policy) within an apparently harmless request. Like response
1988 splitting, request smuggling can lead to a variety of attacks on HTTP
1989 usage.
1991 This specification has introduced new requirements on request
1992 parsing, particularly with regard to message framing in Section 6.3,
1993 to reduce the effectiveness of request smuggling.
1995 11.3. Message Integrity
1997 HTTP does not define a specific mechanism for ensuring message
1998 integrity, instead relying on the error-detection ability of
1999 underlying transport protocols and the use of length or chunk-
2000 delimited framing to detect completeness. Additional integrity
2001 mechanisms, such as hash functions or digital signatures applied to
2002 the content, can be selectively added to messages via extensible
2003 metadata fields. Historically, the lack of a single integrity
2004 mechanism has been justified by the informal nature of most HTTP
2005 communication. However, the prevalence of HTTP as an information
2006 access mechanism has resulted in its increasing use within
2007 environments where verification of message integrity is crucial.
2009 User agents are encouraged to implement configurable means for
2010 detecting and reporting failures of message integrity such that those
2011 means can be enabled within environments for which integrity is
2012 necessary. For example, a browser being used to view medical history
2013 or drug interaction information needs to indicate to the user when
2014 such information is detected by the protocol to be incomplete,
2015 expired, or corrupted during transfer. Such mechanisms might be
2016 selectively enabled via user agent extensions or the presence of
2017 message integrity metadata in a response. At a minimum, user agents
2018 ought to provide some indication that allows a user to distinguish
2019 between a complete and incomplete response message (Section 8) when
2020 such verification is desired.
2022 11.4. Message Confidentiality
2024 HTTP relies on underlying transport protocols to provide message
2025 confidentiality when that is desired. HTTP has been specifically
2026 designed to be independent of the transport protocol, such that it
2027 can be used over many different forms of encrypted connection, with
2028 the selection of such transports being identified by the choice of
2029 URI scheme or within user agent configuration.
2031 The "https" scheme can be used to identify resources that require a
2032 confidential connection, as described in Section 2.5.2 of
2033 [Semantics].
2035 12. IANA Considerations
2037 The change controller for the following registrations is: "IETF
2038 (iesg@ietf.org) - Internet Engineering Task Force".
2040 12.1. Field Name Registration
2042 Please update the "Hypertext Transfer Protocol (HTTP) Field Name
2043 Registry" at with the
2044 field names listed in the two tables of Section 5.
2046 12.2. Media Type Registration
2048 Please update the "Media Types" registry at
2049 with the registration
2050 information in Section 10.1 and Section 10.2 for the media types
2051 "message/http" and "application/http", respectively.
2053 12.3. Transfer Coding Registration
2055 Please update the "HTTP Transfer Coding Registry" at
2056 with the
2057 registration procedure of Section 7.3 and the content coding names
2058 summarized in the table of Section 7.
2060 12.4. Upgrade Token Registration
2062 Please update the "Hypertext Transfer Protocol (HTTP) Upgrade Token
2063 Registry" at
2064 with the registration procedure of Section 9.9.2 and the upgrade
2065 token names summarized in the table of Section 9.9.1.
2067 12.5. ALPN Protocol ID Registration
2069 Please update the "TLS Application-Layer Protocol Negotiation (ALPN)
2070 Protocol IDs" registry at with the
2072 registration below:
2074 +----------+--------------------------------------+-----------------+
2075 | Protocol | Identification Sequence | Reference |
2076 +----------+--------------------------------------+-----------------+
2077 | HTTP/1.1 | 0x68 0x74 0x74 0x70 0x2f 0x31 0x2e | (this |
2078 | | 0x31 ("http/1.1") | specification) |
2079 +----------+--------------------------------------+-----------------+
2081 13. References
2083 13.1. Normative References
2085 [Caching] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke,
2086 Ed., "HTTP Caching", draft-ietf-httpbis-cache-09 (work in
2087 progress), July 2020.
2089 [RFC1950] Deutsch, L. and J-L. Gailly, "ZLIB Compressed Data Format
2090 Specification version 3.3", RFC 1950,
2091 DOI 10.17487/RFC1950, May 1996,
2092 .
2094 [RFC1951] Deutsch, P., "DEFLATE Compressed Data Format Specification
2095 version 1.3", RFC 1951, DOI 10.17487/RFC1951, May 1996,
2096 .
2098 [RFC1952] Deutsch, P., Gailly, J-L., Adler, M., Deutsch, L., and G.
2099 Randers-Pehrson, "GZIP file format specification version
2100 4.3", RFC 1952, DOI 10.17487/RFC1952, May 1996,
2101 .
2103 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
2104 Requirement Levels", BCP 14, RFC 2119,
2105 DOI 10.17487/RFC2119, March 1997,
2106 .
2108 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
2109 Resource Identifier (URI): Generic Syntax", STD 66,
2110 RFC 3986, DOI 10.17487/RFC3986, January 2005,
2111 .
2113 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax
2114 Specifications: ABNF", STD 68, RFC 5234,
2115 DOI 10.17487/RFC5234, January 2008,
2116 .
2118 [RFC7405] Kyzivat, P., "Case-Sensitive String Support in ABNF",
2119 RFC 7405, DOI 10.17487/RFC7405, December 2014,
2120 .
2122 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
2123 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
2124 May 2017, .
2126 [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol
2127 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018,
2128 .
2130 [Semantics]
2131 Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke,
2132 Ed., "HTTP Semantics", draft-ietf-httpbis-semantics-09
2133 (work in progress), July 2020.
2135 [USASCII] American National Standards Institute, "Coded Character
2136 Set -- 7-bit American Standard Code for Information
2137 Interchange", ANSI X3.4, 1986.
2139 [Welch] Welch, T., "A Technique for High-Performance Data
2140 Compression", IEEE Computer 17(6), June 1984.
2142 13.2. Informative References
2144 [Err4667] RFC Errata, Erratum ID 4667, RFC 7230,
2145 .
2147 [Klein] Klein, A., "Divide and Conquer - HTTP Response Splitting,
2148 Web Cache Poisoning Attacks, and Related Topics", March
2149 2004, .
2152 [Linhart] Linhart, C., Klein, A., Heled, R., and S. Orrin, "HTTP
2153 Request Smuggling", June 2005,
2154 .
2156 [RFC1945] Berners-Lee, T., Fielding, R., and H. Nielsen, "Hypertext
2157 Transfer Protocol -- HTTP/1.0", RFC 1945,
2158 DOI 10.17487/RFC1945, May 1996,
2159 .
2161 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail
2162 Extensions (MIME) Part One: Format of Internet Message
2163 Bodies", RFC 2045, DOI 10.17487/RFC2045, November 1996,
2164 .
2166 [RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail
2167 Extensions (MIME) Part Two: Media Types", RFC 2046,
2168 DOI 10.17487/RFC2046, November 1996,
2169 .
2171 [RFC2049] Freed, N. and N. Borenstein, "Multipurpose Internet Mail
2172 Extensions (MIME) Part Five: Conformance Criteria and
2173 Examples", RFC 2049, DOI 10.17487/RFC2049, November 1996,
2174 .
2176 [RFC2068] Fielding, R., Gettys, J., Mogul, J., Nielsen, H., and T.
2177 Berners-Lee, "Hypertext Transfer Protocol -- HTTP/1.1",
2178 RFC 2068, DOI 10.17487/RFC2068, January 1997,
2179 .
2181 [RFC2557] Palme, F., Hopmann, A., Shelness, N., and E. Stefferud,
2182 "MIME Encapsulation of Aggregate Documents, such as HTML
2183 (MHTML)", RFC 2557, DOI 10.17487/RFC2557, March 1999,
2184 .
2186 [RFC5322] Resnick, P., "Internet Message Format", RFC 5322,
2187 DOI 10.17487/RFC5322, October 2008,
2188 .
2190 [RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
2191 Protocol (HTTP/1.1): Message Syntax and Routing",
2192 RFC 7230, DOI 10.17487/RFC7230, June 2014,
2193 .
2195 [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
2196 Protocol (HTTP/1.1): Semantics and Content", RFC 7231,
2197 DOI 10.17487/RFC7231, June 2014,
2198 .
2200 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for
2201 Writing an IANA Considerations Section in RFCs", BCP 26,
2202 RFC 8126, DOI 10.17487/RFC8126, June 2017,
2203 .
2205 Appendix A. Collected ABNF
2207 In the collected ABNF below, list rules are expanded as per
2208 Section 5.5.1 of [Semantics].
2210 BWS =
2212 Connection = connection-option *( OWS "," OWS connection-option )
2214 HTTP-message = start-line CRLF *( field-line CRLF ) CRLF [
2215 message-body ]
2216 HTTP-name = %x48.54.54.50 ; HTTP
2217 HTTP-version = HTTP-name "/" DIGIT "." DIGIT
2219 OWS =
2221 RWS =
2223 TE = [ t-codings *( OWS "," OWS t-codings ) ]
2224 Transfer-Encoding = transfer-coding *( OWS "," OWS transfer-coding )
2226 Upgrade = protocol *( OWS "," OWS protocol )
2228 absolute-URI =
2229 absolute-form = absolute-URI
2230 absolute-path =
2231 asterisk-form = "*"
2232 authority =
2233 authority-form = authority
2235 chunk = chunk-size [ chunk-ext ] CRLF chunk-data CRLF
2236 chunk-data = 1*OCTET
2237 chunk-ext = *( BWS ";" BWS chunk-ext-name [ BWS "=" BWS chunk-ext-val
2238 ] )
2239 chunk-ext-name = token
2240 chunk-ext-val = token / quoted-string
2241 chunk-size = 1*HEXDIG
2242 chunked-body = *chunk last-chunk trailer-section CRLF
2243 comment =
2244 connection-option = token
2246 field-line = field-name ":" OWS field-value OWS
2247 field-name =
2248 field-value =
2250 last-chunk = 1*"0" [ chunk-ext ] CRLF
2252 message-body = *OCTET
2253 method = token
2255 obs-fold = OWS CRLF RWS
2256 obs-text =
2257 origin-form = absolute-path [ "?" query ]
2259 port =
2260 protocol = protocol-name [ "/" protocol-version ]
2261 protocol-name = token
2262 protocol-version = token
2264 query =
2265 quoted-string =
2267 rank = ( "0" [ "." *3DIGIT ] ) / ( "1" [ "." *3"0" ] )
2268 reason-phrase = 1*( HTAB / SP / VCHAR / obs-text )
2269 request-line = method SP request-target SP HTTP-version
2270 request-target = origin-form / absolute-form / authority-form /
2271 asterisk-form
2273 start-line = request-line / status-line
2274 status-code = 3DIGIT
2275 status-line = HTTP-version SP status-code SP [ reason-phrase ]
2277 t-codings = "trailers" / ( transfer-coding [ t-ranking ] )
2278 t-ranking = OWS ";" OWS "q=" rank
2279 token =
2280 trailer-section = *( field-line CRLF )
2281 transfer-coding = token *( OWS ";" OWS transfer-parameter )
2282 transfer-parameter = token BWS "=" BWS ( token / quoted-string )
2284 uri-host =
2286 Appendix B. Differences between HTTP and MIME
2288 HTTP/1.1 uses many of the constructs defined for the Internet Message
2289 Format [RFC5322] and the Multipurpose Internet Mail Extensions (MIME)
2290 [RFC2045] to allow a message body to be transmitted in an open
2291 variety of representations and with extensible fields. However, RFC
2292 2045 is focused only on email; applications of HTTP have many
2293 characteristics that differ from email; hence, HTTP has features that
2294 differ from MIME. These differences were carefully chosen to
2295 optimize performance over binary connections, to allow greater
2296 freedom in the use of new media types, to make date comparisons
2297 easier, and to acknowledge the practice of some early HTTP servers
2298 and clients.
2300 This appendix describes specific areas where HTTP differs from MIME.
2301 Proxies and gateways to and from strict MIME environments need to be
2302 aware of these differences and provide the appropriate conversions
2303 where necessary.
2305 B.1. MIME-Version
2307 HTTP is not a MIME-compliant protocol. However, messages can include
2308 a single MIME-Version header field to indicate what version of the
2309 MIME protocol was used to construct the message. Use of the MIME-
2310 Version header field indicates that the message is in full
2311 conformance with the MIME protocol (as defined in [RFC2045]).
2312 Senders are responsible for ensuring full conformance (where
2313 possible) when exporting HTTP messages to strict MIME environments.
2315 B.2. Conversion to Canonical Form
2317 MIME requires that an Internet mail body part be converted to
2318 canonical form prior to being transferred, as described in Section 4
2319 of [RFC2049]. Section 7.1.1.2 of [Semantics] describes the forms
2320 allowed for subtypes of the "text" media type when transmitted over
2321 HTTP. [RFC2046] requires that content with a type of "text"
2322 represent line breaks as CRLF and forbids the use of CR or LF outside
2323 of line break sequences. HTTP allows CRLF, bare CR, and bare LF to
2324 indicate a line break within text content.
2326 A proxy or gateway from HTTP to a strict MIME environment ought to
2327 translate all line breaks within text media types to the RFC 2049
2328 canonical form of CRLF. Note, however, this might be complicated by
2329 the presence of a Content-Encoding and by the fact that HTTP allows
2330 the use of some charsets that do not use octets 13 and 10 to
2331 represent CR and LF, respectively.
2333 Conversion will break any cryptographic checksums applied to the
2334 original content unless the original content is already in canonical
2335 form. Therefore, the canonical form is recommended for any content
2336 that uses such checksums in HTTP.
2338 B.3. Conversion of Date Formats
2340 HTTP/1.1 uses a restricted set of date formats (Section 5.4.1.5 of
2341 [Semantics]) to simplify the process of date comparison. Proxies and
2342 gateways from other protocols ought to ensure that any Date header
2343 field present in a message conforms to one of the HTTP/1.1 formats
2344 and rewrite the date if necessary.
2346 B.4. Conversion of Content-Encoding
2348 MIME does not include any concept equivalent to HTTP/1.1's Content-
2349 Encoding header field. Since this acts as a modifier on the media
2350 type, proxies and gateways from HTTP to MIME-compliant protocols
2351 ought to either change the value of the Content-Type header field or
2352 decode the representation before forwarding the message. (Some
2353 experimental applications of Content-Type for Internet mail have used
2354 a media-type parameter of ";conversions=" to perform
2355 a function equivalent to Content-Encoding. However, this parameter
2356 is not part of the MIME standards).
2358 B.5. Conversion of Content-Transfer-Encoding
2360 HTTP does not use the Content-Transfer-Encoding field of MIME.
2361 Proxies and gateways from MIME-compliant protocols to HTTP need to
2362 remove any Content-Transfer-Encoding prior to delivering the response
2363 message to an HTTP client.
2365 Proxies and gateways from HTTP to MIME-compliant protocols are
2366 responsible for ensuring that the message is in the correct format
2367 and encoding for safe transport on that protocol, where "safe
2368 transport" is defined by the limitations of the protocol being used.
2369 Such a proxy or gateway ought to transform and label the data with an
2370 appropriate Content-Transfer-Encoding if doing so will improve the
2371 likelihood of safe transport over the destination protocol.
2373 B.6. MHTML and Line Length Limitations
2375 HTTP implementations that share code with MHTML [RFC2557]
2376 implementations need to be aware of MIME line length limitations.
2377 Since HTTP does not have this limitation, HTTP does not fold long
2378 lines. MHTML messages being transported by HTTP follow all
2379 conventions of MHTML, including line length limitations and folding,
2380 canonicalization, etc., since HTTP transfers message-bodies as
2381 payload and, aside from the "multipart/byteranges" type
2382 (Section 7.3.5 of [Semantics]), does not interpret the content or any
2383 MIME header lines that might be contained therein.
2385 Appendix C. HTTP Version History
2387 HTTP has been in use since 1990. The first version, later referred
2388 to as HTTP/0.9, was a simple protocol for hypertext data transfer
2389 across the Internet, using only a single request method (GET) and no
2390 metadata. HTTP/1.0, as defined by [RFC1945], added a range of
2391 request methods and MIME-like messaging, allowing for metadata to be
2392 transferred and modifiers placed on the request/response semantics.
2393 However, HTTP/1.0 did not sufficiently take into consideration the
2394 effects of hierarchical proxies, caching, the need for persistent
2395 connections, or name-based virtual hosts. The proliferation of
2396 incompletely implemented applications calling themselves "HTTP/1.0"
2397 further necessitated a protocol version change in order for two
2398 communicating applications to determine each other's true
2399 capabilities.
2401 HTTP/1.1 remains compatible with HTTP/1.0 by including more stringent
2402 requirements that enable reliable implementations, adding only those
2403 features that can either be safely ignored by an HTTP/1.0 recipient
2404 or only be sent when communicating with a party advertising
2405 conformance with HTTP/1.1.
2407 HTTP/1.1 has been designed to make supporting previous versions easy.
2408 A general-purpose HTTP/1.1 server ought to be able to understand any
2409 valid request in the format of HTTP/1.0, responding appropriately
2410 with an HTTP/1.1 message that only uses features understood (or
2411 safely ignored) by HTTP/1.0 clients. Likewise, an HTTP/1.1 client
2412 can be expected to understand any valid HTTP/1.0 response.
2414 Since HTTP/0.9 did not support header fields in a request, there is
2415 no mechanism for it to support name-based virtual hosts (selection of
2416 resource by inspection of the Host header field). Any server that
2417 implements name-based virtual hosts ought to disable support for
2418 HTTP/0.9. Most requests that appear to be HTTP/0.9 are, in fact,
2419 badly constructed HTTP/1.x requests caused by a client failing to
2420 properly encode the request-target.
2422 C.1. Changes from HTTP/1.0
2424 This section summarizes major differences between versions HTTP/1.0
2425 and HTTP/1.1.
2427 C.1.1. Multihomed Web Servers
2429 The requirements that clients and servers support the Host header
2430 field (Section 6.6 of [Semantics]), report an error if it is missing
2431 from an HTTP/1.1 request, and accept absolute URIs (Section 3.2) are
2432 among the most important changes defined by HTTP/1.1.
2434 Older HTTP/1.0 clients assumed a one-to-one relationship of IP
2435 addresses and servers; there was no other established mechanism for
2436 distinguishing the intended server of a request than the IP address
2437 to which that request was directed. The Host header field was
2438 introduced during the development of HTTP/1.1 and, though it was
2439 quickly implemented by most HTTP/1.0 browsers, additional
2440 requirements were placed on all HTTP/1.1 requests in order to ensure
2441 complete adoption. At the time of this writing, most HTTP-based
2442 services are dependent upon the Host header field for targeting
2443 requests.
2445 C.1.2. Keep-Alive Connections
2447 In HTTP/1.0, each connection is established by the client prior to
2448 the request and closed by the server after sending the response.
2449 However, some implementations implement the explicitly negotiated
2450 ("Keep-Alive") version of persistent connections described in
2451 Section 19.7.1 of [RFC2068].
2453 Some clients and servers might wish to be compatible with these
2454 previous approaches to persistent connections, by explicitly
2455 negotiating for them with a "Connection: keep-alive" request header
2456 field. However, some experimental implementations of HTTP/1.0
2457 persistent connections are faulty; for example, if an HTTP/1.0 proxy
2458 server doesn't understand Connection, it will erroneously forward
2459 that header field to the next inbound server, which would result in a
2460 hung connection.
2462 One attempted solution was the introduction of a Proxy-Connection
2463 header field, targeted specifically at proxies. In practice, this
2464 was also unworkable, because proxies are often deployed in multiple
2465 layers, bringing about the same problem discussed above.
2467 As a result, clients are encouraged not to send the Proxy-Connection
2468 header field in any requests.
2470 Clients are also encouraged to consider the use of Connection: keep-
2471 alive in requests carefully; while they can enable persistent
2472 connections with HTTP/1.0 servers, clients using them will need to
2473 monitor the connection for "hung" requests (which indicate that the
2474 client ought stop sending the header field), and this mechanism ought
2475 not be used by clients at all when a proxy is being used.
2477 C.1.3. Introduction of Transfer-Encoding
2479 HTTP/1.1 introduces the Transfer-Encoding header field (Section 6.1).
2480 Transfer codings need to be decoded prior to forwarding an HTTP
2481 message over a MIME-compliant protocol.
2483 C.2. Changes from RFC 7230
2485 Most of the sections introducing HTTP's design goals, history,
2486 architecture, conformance criteria, protocol versioning, URIs,
2487 message routing, and header fields have been moved to [Semantics].
2488 This document has been reduced to just the messaging syntax and
2489 connection management requirements specific to HTTP/1.1.
2491 Prohibited generation of bare CRs outside of payload body.
2492 (Section 2.2)
2494 In the ABNF for chunked extensions, re-introduced (bad) whitespace
2495 around ";" and "=". Whitespace was removed in [RFC7230], but that
2496 change was found to break existing implementations (see [Err4667]).
2497 (Section 7.1.1)
2499 Trailer field semantics now transcend the specifics of chunked
2500 encoding. The decoding algorithm for chunked (Section 7.1.3) has
2501 been updated to encourage storage/forwarding of trailer fields
2502 separately from the header section, to only allow merging into the
2503 header section if the recipient knows the corresponding field
2504 definition permits and defines how to merge, and otherwise to discard
2505 the trailer fields instead of merging. The trailer part is now
2506 called the trailer section to be more consistent with the header
2507 section and more distinct from a body part. (Section 7.1.2)
2509 Disallowed transfer coding parameters called "q" in order to avoid
2510 conflicts with the use of ranks in the TE header field.
2511 (Section 7.3)
2513 Appendix D. Change Log
2515 This section is to be removed before publishing as an RFC.
2517 D.1. Between RFC7230 and draft 00
2519 The changes were purely editorial:
2521 o Change boilerplate and abstract to indicate the "draft" status,
2522 and update references to ancestor specifications.
2524 o Adjust historical notes.
2526 o Update links to sibling specifications.
2528 o Replace sections listing changes from RFC 2616 by new empty
2529 sections referring to RFC 723x.
2531 o Remove acknowledgements specific to RFC 723x.
2533 o Move "Acknowledgements" to the very end and make them unnumbered.
2535 D.2. Since draft-ietf-httpbis-messaging-00
2537 The changes in this draft are editorial, with respect to HTTP as a
2538 whole, to move all core HTTP semantics into [Semantics]:
2540 o Moved introduction, architecture, conformance, and ABNF extensions
2541 from RFC 7230 (Messaging) to semantics [Semantics].
2543 o Moved discussion of MIME differences from RFC 7231 (Semantics) to
2544 Appendix B since they mostly cover transforming 1.1 messages.
2546 o Moved all extensibility tips, registration procedures, and
2547 registry tables from the IANA considerations to normative
2548 sections, reducing the IANA considerations to just instructions
2549 that will be removed prior to publication as an RFC.
2551 D.3. Since draft-ietf-httpbis-messaging-01
2553 o Cite RFC 8126 instead of RFC 5226 ()
2556 o Resolved erratum 4779, no change needed here
2557 (,
2558 )
2560 o In Section 7, fixed prose claiming transfer parameters allow bare
2561 names (,
2562 )
2564 o Resolved erratum 4225, no change needed here
2565 (,
2566 )
2568 o Replace "response code" with "response status code"
2569 (,
2570 )
2572 o In Section 9.4, clarify statement about HTTP/1.0 keep-alive
2573 (,
2574 )
2576 o In Section 7.1.1, re-introduce (bad) whitespace around ";" and "="
2577 (,
2578 , )
2581 o In Section 7.3, state that transfer codings should not use
2582 parameters named "q" (, )
2585 o In Section 7, mark coding name "trailers" as reserved in the IANA
2586 registry ()
2588 D.4. Since draft-ietf-httpbis-messaging-02
2590 o In Section 4, explain why the reason phrase should be ignored by
2591 clients ().
2593 o Add Section 9.3 to explain how request/response correlation is
2594 performed ()
2596 D.5. Since draft-ietf-httpbis-messaging-03
2598 o In Section 9.3, caution against treating data on a connection as
2599 part of a not-yet-issued request ()
2602 o In Section 7, remove the predefined codings from the ABNF and make
2603 it generic instead ()
2606 o Use RFC 7405 ABNF notation for case-sensitive string constants
2607 ()
2609 D.6. Since draft-ietf-httpbis-messaging-04
2611 o In Section 9.9, clarify that protocol-name is to be matched case-
2612 insensitively ()
2614 o In Section 5.2, add leading optional whitespace to obs-fold ABNF
2615 (,
2616 )
2618 o In Section 4, add clarifications about empty reason phrases
2619 ()
2621 o Move discussion of retries from Section 9.4.1 into [Semantics]
2622 ()
2624 D.7. Since draft-ietf-httpbis-messaging-05
2626 o In Section 7.1.2, the trailer part has been renamed the trailer
2627 section (for consistency with the header section) and trailers are
2628 no longer merged as header fields by default, but rather can be
2629 discarded, kept separate from header fields, or merged with header
2630 fields only if understood and defined as being mergeable
2631 ()
2633 o In Section 2.1 and related Sections, move the trailing CRLF from
2634 the line grammars into the message format
2635 ()
2637 o Moved Section 2.3 down ()
2640 o In Section 9.9, use 'websocket' instead of 'HTTP/2.0' in examples
2641 ()
2643 o Move version non-specific text from Section 6 into semantics as
2644 "payload body" ()
2646 o In Section 9.8, add text from RFC 2818
2647 ()
2649 D.8. Since draft-ietf-httpbis-messaging-06
2651 o In Section 12.5, update the APLN protocol id for HTTP/1.1
2652 ()
2654 o In Section 5, align with updates to field terminology in semantics
2655 ()
2657 o In Section 9.1, clarify that new connection options indeed need to
2658 be registered ()
2660 o In Section 1.1, reference RFC 8174 as well
2661 ()
2663 D.9. Since draft-ietf-httpbis-messaging-07
2665 o Move TE: trailers into [Semantics] ()
2668 o In Section 6.3, adjust requirements for handling multiple content-
2669 length values ()
2671 o Throughout, replace "effective request URI" with "target URI"
2672 ()
2674 o In Section 6.1, don't claim Transfer-Encoding is supported by
2675 HTTP/2 or later ()
2677 D.10. Since draft-ietf-httpbis-messaging-08
2679 o In Section 2.2, disallow bare CRs ()
2682 o Appendix A now uses the sender variant of the "#" list expansion
2683 ()
2685 o In Section 5, adjust IANA "Close" entry for new registry format
2686 ()
2688 Index
2690 A
2691 absolute-form (of request-target) 11
2692 application/http Media Type 41
2693 asterisk-form (of request-target) 12
2694 authority-form (of request-target) 12
2696 C
2697 Connection header field 29, 34
2698 Content-Length header field 19
2699 Content-Transfer-Encoding header field 52
2700 chunked (Coding Format) 18, 20
2701 chunked (transfer coding) 23
2702 close 29, 34
2703 compress (transfer coding) 26
2705 D
2706 deflate (transfer coding) 26
2708 F
2709 Fields
2710 Connection 29
2711 MIME-Version 51
2712 TE 27
2713 Transfer-Encoding 18
2714 Upgrade 36
2716 G
2717 Grammar
2718 absolute-form 10-11
2719 ALPHA 5
2720 asterisk-form 10, 12
2721 authority-form 10, 12
2722 chunk 23
2723 chunk-data 23
2724 chunk-ext 23-24
2725 chunk-ext-name 24
2726 chunk-ext-val 24
2727 chunk-size 23
2728 chunked-body 23
2729 Connection 30
2730 connection-option 30
2731 CR 5
2732 CRLF 5
2733 CTL 5
2734 DIGIT 5
2735 DQUOTE 5
2736 field-line 15, 25
2737 field-name 15
2738 field-value 15
2739 HEXDIG 5
2740 HTAB 5
2741 HTTP-message 6
2742 HTTP-name 8
2743 HTTP-version 8
2744 last-chunk 23
2745 LF 5
2746 message-body 17
2747 method 10
2748 obs-fold 16
2749 OCTET 5
2750 origin-form 10
2751 rank 27
2752 reason-phrase 15
2753 request-line 9
2754 request-target 10
2755 SP 5
2756 start-line 6
2757 status-code 15
2758 status-line 14
2759 t-codings 27
2760 t-ranking 27
2761 TE 27
2762 trailer-section 23, 25
2763 transfer-coding 22
2764 Transfer-Encoding 18
2765 transfer-parameter 22
2766 Upgrade 37
2767 VCHAR 5
2768 gzip (transfer coding) 26
2770 H
2771 Header Fields
2772 Connection 29
2773 MIME-Version 51
2774 TE 27
2775 Transfer-Encoding 18
2776 Upgrade 36
2777 header line 6
2778 header section 6
2779 headers 6
2781 M
2782 MIME-Version header field 51
2783 Media Type
2784 application/http 41
2785 message/http 40
2786 message/http Media Type 40
2787 method 10
2789 O
2790 origin-form (of request-target) 10
2792 R
2793 request-target 10
2795 T
2796 TE header field 27
2797 Transfer-Encoding header field 18
2799 U
2800 Upgrade header field 36
2802 X
2803 x-compress (transfer coding) 26
2804 x-gzip (transfer coding) 26
2806 Acknowledgments
2808 See Appendix "Acknowledgments" of [Semantics].
2810 Authors' Addresses
2812 Roy T. Fielding (editor)
2813 Adobe
2814 345 Park Ave
2815 San Jose, CA 95110
2816 United States of America
2818 EMail: fielding@gbiv.com
2819 URI: https://roy.gbiv.com/
2820 Mark Nottingham (editor)
2821 Fastly
2823 EMail: mnot@mnot.net
2824 URI: https://www.mnot.net/
2826 Julian F. Reschke (editor)
2827 greenbytes GmbH
2828 Hafenweg 16
2829 Muenster 48155
2830 Germany
2832 EMail: julian.reschke@greenbytes.de
2833 URI: https://greenbytes.de/tech/webdav/