Skip to content

Commit 79e62d8

Browse files
committed
delete gzip header once decompressed
FilterResp detects `Content-Encoding: gzip` and decompresses the body into plain bytes. But it never removed the `Content-Encoding: gzip` header before passing the response back to the client
1 parent c53a8e1 commit 79e62d8

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

pkg/authz/responsefilterer.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ func (rf *StandardResponseFilterer) FilterResp(resp *http.Response) error {
250250
defer func() {
251251
_ = bodyStream.Close()
252252
}()
253+
// We're decompressing the body here, so remove the header.
254+
// If we leave it, the downstream HTTP transport will try to
255+
// gzip-decompress the already-plain bytes and fail with
256+
// "gzip: invalid header".
257+
resp.Header.Del("Content-Encoding")
253258
}
254259

255260
body, err := io.ReadAll(bodyStream)

0 commit comments

Comments
 (0)