Skip to content

Commit c5e03f5

Browse files
authored
Merge pull request #15 from liquify-validation/copy-all-headers
copy all headers
2 parents f8fd4df + e760faf commit c5e03f5

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

API_gateway/proxy/proxy/http.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,23 @@ func ProxyHttpRequest(ctx *fasthttp.RequestCtx, req *fasthttp.Request, chain str
130130
// Forward upstream status and body as-is (even if non-2xx)
131131
ctx.SetStatusCode(backendResp.StatusCode())
132132

133-
// Copy a minimal, safe subset of headers
133+
// Copy all headers except hop-by-hop ones. This preserves Content-Encoding/Vary/etc.
134+
hopByHop := map[string]struct{}{
135+
"connection": {},
136+
"keep-alive": {},
137+
"proxy-authenticate": {},
138+
"proxy-authorization": {},
139+
"te": {},
140+
"trailer": {},
141+
"transfer-encoding": {},
142+
"upgrade": {},
143+
}
144+
134145
backendResp.Header.VisitAll(func(k, v []byte) {
135-
switch strings.ToLower(string(k)) {
136-
case "content-type", "cache-control", "etag", "last-modified":
137-
ctx.Response.Header.SetBytesKV(k, v)
146+
if _, skip := hopByHop[strings.ToLower(string(k))]; skip {
147+
return
138148
}
149+
ctx.Response.Header.SetBytesKV(k, v)
139150
})
140151

141152
// Copy body before releasing the response object

0 commit comments

Comments
 (0)