Re: [whatwg/fetch] Streaming upload (Issue #1438)

Ok, so from chatting on Matrix, I think this approach would solve all of my concerns, and I think all of the ones brought up in this thread and #1254 too:

1. A new `duplex` option is added to `RequestInit`. It has valid values of `"half"` and `"full"`.
2. If the `body` option is unset, or is set to anything other than a `ReadableStream`, `duplex` defaults to `"half"`.
3. If the `body` option is a `ReadableStream`, `duplex` must be manually specified by the user (no default).
4. For now, browsers will only support `duplex: "half"`.
5. Because in Deno there are existing users that rely on `ReadableStream` bodies being `duplex: "full"`, Deno will need to deviate from spec by defaulting to `duplex: "full"` for when `body` is a `ReadableStream`. For non-`ReadableStream` bodies, the default would match `duplex: "half"` (and thus match browsers).
6. `duplex: "half"` is the currently specified behavior where the `Promise` returned from `fetch` only resolves when both the request body stream is fully sent and the response headers have been received.
7. `duplex: "full"` is a future addition to the specification that would cause the `Promise` returned from `fetch` to resolve immediately when the response headers have been received, regardless of if the request body has been fully sent. We are happy to do the spec work for this addition in a follow up.

Does anyone have concerns that this approach does not resolve?

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

Message ID: <whatwg/fetch/issues/1438/1158981343@github.com>

Received on Friday, 17 June 2022 15:25:40 UTC