- From: Jake Champion <notifications@github.com>
- Date: Tue, 18 Jul 2023 04:38:28 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/fetch/issues/981/1640053514@github.com>
Howdy all, I work at Fastly on their JavaScript runtime and SDK 👋 Fastly are interested in implementing HTTP Trailer support in order to support gRPC over HTTP/2. I would like to implement the HTTP Trailer support in a standard compatible way, and would be happy to work with folks on bringing this functionality into the Fetch Standard. What I am thinking as a potential solution is: Updating the `Response` interface to include a new `trailers` method which returns a `Promise<Headers>` instance: ```webidl [SameObject] Promise<Headers> trailers(); ``` Updating the `ResponseInit` interface to include a new `trailers` field which implements the `HeadersInit` interface ```webidl [HeadersInit](https://fetch.spec.whatwg.org/#typedefdef-headersinit) trailers; ``` And the same for both `Request` and `RequestInit`. Which in an application context would look like this: ```js // Service-Worker API based example of reading a request trailer // and responding with a response which contains the same trailer addEventListener('fetch', event => event.respondWith(app(event))); async function app(event) { const request = event.request; // Resolves when all trailer fields have been received and returns an instance of Headers const incomingTrailers = await request.trailers(); const animal = incomingTrailers.get('animal'); const response = new Response('I am a body', { headers: { 'Trailer': 'animal' }, trailers: { animal: animal }); return response; } ``` -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/issues/981#issuecomment-1640053514 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/fetch/issues/981/1640053514@github.com>
Received on Tuesday, 18 July 2023 11:38:33 UTC