- From: Lucas Pardue <Lucas.Pardue@bbc.co.uk>
- Date: Fri, 26 Jan 2018 18:08:20 +0000
- To: HTTP Working Group <ietf-http-wg@w3.org>
- Message-ID: <7CF7F94CB496BF4FAB1676F375F9666A3BAC90E9@bgb01xud1012>
Hello,
I've been thinking about how a server can approach sending a body of unknown total size.
In HTTP/1.1, we had the chunked transfer coding. From RFC 7230 section 4.1:
The chunked transfer coding wraps the payload body in order to
transfer it as a series of chunks, each with its own size indicator,
followed by an OPTIONAL trailer containing header fields. Chunked
enables content streams of unknown size to be transferred as a
sequence of length-delimited buffers, which enables the sender to
retain connection persistence and the recipient to know when it has
received the entire message.
In HTTP/2, RFC 7540 section 8.1 says
HTTP/2 uses DATA frames to carry message payloads. The "chunked"
transfer encoding defined in Section 4.1 of [RFC7230]<https://tools.ietf.org/html/rfc7230#section-4.1> MUST NOT be
used in HTTP/2.
RFC 7540 section 8.1.3 has an example where it shows how an HTTP/1.1 chunked response could look in HTTP/2 frame form.
HTTP/1.1 200 OK HEADERS
Content-Type: image/jpeg ==> - END_STREAM
Transfer-Encoding: chunked + END_HEADERS
Trailer: Foo :status = 200
content-length = 123
123 content-type = image/jpeg
{binary data} trailer = Foo
0
Foo: bar DATA
- END_STREAM
{binary data}
HEADERS
+ END_STREAM
+ END_HEADERS
foo = bar
The HTTP/1.1 response does not contain a Content-Length header field (presumably because the length is unknown). The HTTP/2 format does include a content-length but I'd argue that the example now implies the length is now known before the payload is sent.
Would it be valid here, to omit the content-length in the HTTP/2 HEADERS?
When thinking through this problem a while back, I had thought that in the HTTP/2 case it would be possible to append the content-length as a trailer but I convinced myself that was also invalid due to a number of other HTTP semantic rules.
Kind regards
Lucas
Received on Friday, 26 January 2018 18:08:46 UTC