Re: [whatwg/fetch] Request body streams should use chunked encoding (#966)

> I would be actively against passing a ReadableStream causing buffering. That completely defeats the point of streams, and I would much rather have fetch() throw if it cannot properly stream the stream.

I think if we can add a switch statement to https://fetch.spec.whatwg.org/#concept-request-transmit-body, one that would switch on the various variables mentioned in this discussion(such as HTTP/1 or /2), and then proceed to transmit bytes accordingly over the network as they are read from the stream. 

I could have imagined the default "we don't know what to do" could be to buffer the bytes, however terminating the fetch could be done at that point as well. I'm not sure if throwing would be possible from there, however it might be done earlier as part of the fetch method(although perhaps code running there should not/cannot be aware of things like whether the network is running HTTP/1 or /2). 

> HTTP/1 uploads need to use chunked encoding.

The current spec already seems to agree, as it is setting the chunked header, in case of a `ReadableStream`(null source), only if the connection is not HTTP/2, at step 4.2 of https://fetch.spec.whatwg.org/#http-network-fetch, with the following wording:

If connection is not an HTTP/2 connection, request’s body is non-null, and request’s body’s source is null, then append `Transfer-Encoding`/`chunked` to request’s header list. 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/966#issuecomment-644231236

Received on Monday, 15 June 2020 16:16:10 UTC