- From: Vitali Lovich <notifications@github.com>
- Date: Wed, 19 Jul 2023 23:01:58 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/fetch/issues/981/1643298401@github.com>
Could deferred proxying take place if the Response object took a promise
for trailer headers rather than a callback? Not sure it’s actually worth it
as I suspect trailer cases require processing the entire body, but just
highlighting the possibility.
On Wed, Jul 19, 2023 at 1:46 PM James M Snell ***@***.***>
wrote:
> 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, view it on GitHub
> <https://github.com/whatwg/fetch/issues/981#issuecomment-1642732284>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AABRERYK57UVQYK4UWODBO3XRBBRJANCNFSM4JZOX5XQ>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/981#issuecomment-1643298401
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/fetch/issues/981/1643298401@github.com>
Received on Thursday, 20 July 2023 06:02:05 UTC