Re: [whatwg/fetch] Trailer support in the API (#981)

Just keeping the conversation going. Based on feedback on the doc I [referenced above](https://docs.google.com/document/d/1P4MskkFd3HHFPGDr01O3wdFXukmX9i0jAb5uh9v9x8Q/edit), I've iterated a bit more on an approach for trailers that should be workable.

Specifically, to send trailers... we can add a new `trailers` option to `RequestInit` and `ResponseInit` whose value is a promise resolving `Headers`.

```js
const resp = await connect('https://...', { method: 'POST', body: payload, trailers: Promise.resolve(trailingHeaders) });
```

When the underlying implementation has completely processed the payload and is ready to send trailing headers, it would await the `trailers` promise.

To receive trailers, we would add a new `trailers` attribute on both `Request` and `Response`.

```js
resp.trailers.then((headers) => {
  // `headers` is a `Headers` object
});
```


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

Message ID: <whatwg/fetch/issues/981/1743158276@github.com>

Received on Monday, 2 October 2023 14:46:45 UTC