Skip to content

Commit

Permalink
Added trailer header support for http/2 (#303)
Browse files Browse the repository at this point in the history
The basic node.js http library uses http/1, so you have to specify 'transfer-encoding: chunked' for requests that include trailers. In http/2 there is no need to specify this header and most sites have stopped doing it. As a result, when the headers are parsed, our server cannot find the header 'transfer-encoding: chunked' and causes an error
  • Loading branch information
sweet-peach authored Mar 1, 2024
1 parent ad79ddc commit 128580a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,11 @@ export class Proxy implements IProxy {
return self._onError("ON_RESPONSE_ERROR", ctx, err);
}
const servToProxyResp = ctx.serverToProxyResponse!;

if (servToProxyResp.headers["trailer"]) {
servToProxyResp.headers["transfer-encoding"] = "chunked";
}

if (
self.responseContentPotentiallyModified ||
ctx.responseContentPotentiallyModified
Expand Down

0 comments on commit 128580a

Please sign in to comment.