fix(HttpClient): let local curl set encoding based what it is built with#53605
Open
joshtrichards wants to merge 1 commit intomasterfrom
Open
fix(HttpClient): let local curl set encoding based what it is built with#53605joshtrichards wants to merge 1 commit intomasterfrom
joshtrichards wants to merge 1 commit intomasterfrom
Conversation
Previously we forced it to gzip but it's possible for a local curl: - not to have been built with gzip - to support additional encoding types In most cases this won't change behavior (i.e. gzip will still be used). Signed-off-by: Josh <josh.t.richards@gmail.com>
This was referenced Aug 22, 2025
Merged
Merged
Merged
Merged
Merged
This was referenced Sep 25, 2025
Merged
Merged
Merged
ernolf
reviewed
Jan 9, 2026
Contributor
There was a problem hiding this comment.
Setting
$options['curl'][CURLOPT_ACCEPT_ENCODING] = '';tells libcurl to advertise all encodings it was built with (e.g. br, zstd, gzip, deflate).
However Guzzle’s response decoding is done in PHP, not by libcurl.
Guzzle only transparently decodes:
- gzip
- deflate
- br only if ext-brotli (brotli_uncompress()) is available
So this configuration can cause a real protocol mismatch:
- libcurl advertises br
- the server selects Content-Encoding: br
- PHP/Guzzle cannot decode it
- the client receives still-compressed bytes and treats them as plain text
That leads to:
- corrupted responses
- JSON decode failures
- empty or garbage payloads
- subtle data corruption with no explicit error
This is not theoretical — most PHP builds ship without ext-brotli, while libcurl in modern distros often supports Brotli and Zstd.
PR #55433 solves this correctly by advertising br only when PHP can actually decode it (function_exists('brotli_uncompress')), otherwise falling back to gzip, with full test coverage.
That keeps HTTP/2 + modern compression while guaranteeing that every negotiated encoding is safely decodable by Guzzle.
This was referenced Jan 29, 2026
Merged
Merged
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.
Summary
This is a mixture of a fix and an enhancement.
In the HTTP client, previously we forced
Accept-Encodingto gzip but it's possible for a local curl:In most cases this won't change behavior (i.e. gzip will still be used). In others, the specific server/client combo will simply choose something "better".
Notes:
Accept-Encodingdocumentation guzzle/guzzle#3215CURLOPT_ACCEPT_ENCODINGis the non-deprecated equivalent ofCURLOPT_ENCODINGChecklist