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

> Not sure if a lot of people use this pattern, but our app was using this code to check if streaming upload is enabled, and it broke for users using browsers based on 105 beta of chromium:
> 
> ```ts
>   public static doesSupportStreamBody (): boolean {
>     // This works because the browser adds a Content-Type header of text/plain;charset=UTF-8 to the request 
>     // if the body is text. 
>     // The browser only treats the body as text if it doesn't support request streams, 
>     // otherwise it won't add a Content-Type header at all.
>     return ReadableStream && !new Request('', {
>         body: new ReadableStream(),
>         method: 'POST',
>       }).headers.has('Content-Type')
>   }
> ```
> 
> We had to add this to fix it:
> 
> ```ts
>         // @ts-expect-error
>         duplex: 'half',
> ```

Thank you for noting this. It appears that this requirement is documented in the [fetch standard](https://fetch.spec.whatwg.org/#ref-for-dom-requestinit-duplex) but nowhere else. I am planning on submitting a few pull requests for MDN to add something. 

Thoughts?

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

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

Received on Monday, 26 December 2022 23:35:03 UTC