- From: James M Snell <notifications@github.com>
- Date: Mon, 02 Oct 2023 07:58:44 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 2 October 2023 14:58:50 UTC
### What problem are you trying to solve? Early hints (103 responses) are not the only kind of interim response the http spec allows for. It would be ideal for fetch to provide a means of receiving and processing interim responses. ### What solutions exist today? For fetch, none. ### How would you solve it? Define a new `InterimResponse` dictionary: ``` dictionary InterimResponse { unsigned short status; ByteString statusText; USVString url; Headers headers; } ``` Define a new `FetchPromise` that extends `Promise<Response>` and implements `Symbol.asyncIterator`, returning an `AsyncIterable` of `InterimResponse`s. The `fetch()` method would return this new `FetchPromise`, allowing, for example: ``` const fetchPromise = fetch('https://...'); // note no await for await (const interimResponse of fetchPromise) { // process the interim response } const resp = await fetchPromise; ``` ### Anything else? Original discussion for this mechanism here: https://docs.google.com/document/d/1P4MskkFd3HHFPGDr01O3wdFXukmX9i0jAb5uh9v9x8Q/edit -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/issues/1716 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/fetch/issues/1716@github.com>
Received on Monday, 2 October 2023 14:58:50 UTC