- From: James M Snell <notifications@github.com>
- Date: Wed, 19 Jul 2023 13:46:19 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Wednesday, 19 July 2023 20:46:24 UTC
Keep in mind that these are reversed on client and server sides. On the client side, a `trailers` callback would need to be provided in the `RequestInit`, while on the server-side, it needs to be on the `ResponseInit`. On the receiving side, setting up an "on trailers" callback would avoid the issue of ordering when consuming the body. ``` // client side fetch api const resp = await fetch('http://example.org', { headers: { 'trailers': 'foo' }, // Called when sending the headers... trailers(headers) { headers.set('foo', 'bar'); } } resp.ontrailers = (headers) => { // Called when trailers are received. }; ``` ``` // server side fetch api export default { async fetch(req) { req.ontrailers = (headers) => { // Called when trailers are received }; // ... return new Response(stream, { headers: { 'trailers': 'foo' }, trailers(headers) { headers.set('foo', 'bar'); } }); } } ``` -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/issues/981#issuecomment-1642732284 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/fetch/issues/981/1642732284@github.com>
Received on Wednesday, 19 July 2023 20:46:24 UTC