Add decompressRequest filter for handling compressed request body#4023
Draft
Abdelghafour01 wants to merge 1 commit into
Draft
Add decompressRequest filter for handling compressed request body#4023Abdelghafour01 wants to merge 1 commit into
Abdelghafour01 wants to merge 1 commit into
Conversation
…sing existing decoders (gzip, deflate, br, zstd) Signed-off-by: Abdelghafour Mourchid <Abdelghafour01@users.noreply.github.com>
505d9c1 to
18549ac
Compare
szuecs
reviewed
May 23, 2026
| } | ||
| if got := ctx.Request().Header.Get("Content-Encoding"); got != "unsupported" { | ||
| t.Errorf("expected Content-Encoding to be preserved when unsupported, got: %q", got) | ||
| } |
Member
There was a problem hiding this comment.
Can you please also check the body contains "x"?
| } | ||
| } | ||
|
|
||
| func TestDecompressRequestInvalidPayload(t *testing.T) { |
Member
There was a problem hiding this comment.
If we detect this we should respond by a 400, right?
If so I would say we should also test it.
Member
|
@Abdelghafour01 thanks for the pr, looks great and there are only a bit of ideas what we can further improve by testing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description
Add
decompressRequestfilterAdds a new filter
decompressRequest()that decompresses the request body on the request path, mirroring the existingdecompress()filter that operates on response bodies.Motivation
Skipper currently supports decompressing response bodies via the
decompress()filter, but there is no equivalent for request bodies. Backends that don't natively understand compressed request payloads (e.g. clients sendingContent-Encoding: gziponPOST/PUT) can't be transparently fronted by Skipper today. This filter closes that gap.Changes
decompressRequest().Content-Encodingheader and streams the body through the appropriate decoder.gzip,deflate,br,zstd(reusesnewDecodedBody,getEncodings,encodingsSupportedfrom the existingdecompressfilter — no duplication of decoder logic or pools).Content-EncodingandContent-Lengthheaders and setsContentLength = -1so the request is sent to the backend as a streamed, decompressed body.filter::decompress::not-possiblein the state bag.http.NoBody, sets bothfilter::decompress::not-possibleandfilter::decompress::errorin the state bag, and logs the error. Same state-bag keys asdecompress()for consistency.DecompressRequestNameconstant in filters.go.ContentLengthcleanupContent-Encodingis passed through unchangedDecompressionNotPossibleand preserves headersDecompressionNotPossibleandDecompressionErrorNote
DecompressionNotPossible,DecompressionError) are intentionally shared withdecompress(); if you'd prefer request-specific keys to disambiguate, happy to split them.