Skip to content

fix(http-client): detect brotli support via libcurl, not PHP extension#60262

Merged
provokateurin merged 2 commits into
masterfrom
ernolf/fix/brotli-detection
May 11, 2026
Merged

fix(http-client): detect brotli support via libcurl, not PHP extension#60262
provokateurin merged 2 commits into
masterfrom
ernolf/fix/brotli-detection

Conversation

@ernolf
Copy link
Copy Markdown
Contributor

@ernolf ernolf commented May 9, 2026

Summary

function_exists('brotli_uncompress') checks the wrong layer.
In Guzzle's curl handler, CURLOPT_ENCODING is set to '' which instructs libcurl to decompress all encodings it was compiled with. All decompression happens inside libcurl. The PHP brotli_uncompress() function is never called in this pipeline.

The wrong check creates two silent failure modes:

  • PHP extension present, libcurl compiled without brotli → server sends Content-Encoding: br, libcurl passes compressed bytes through, application receives garbled data
  • PHP extension absent, libcurl compiled with brotli → brotli is never advertised in Accept-Encoding despite full support

The correct signal is CURL_VERSION_BROTLI in curl_version()['features'], which reflects whether this libcurl binary was compiled with libbrotlidec.
This is also how the Nextcloud News app (FetcherConfig.php) detects brotli support.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

- Fixes a regression introduced in #55433.

Signed-off-by: ernolf <raphael.gradenwitz@googlemail.com>
@ernolf ernolf requested a review from a team as a code owner May 9, 2026 01:46
@ernolf ernolf requested review from ArtificialOwl, CarlSchwan, leftybournes and salmart-dev and removed request for a team May 9, 2026 01:46
@ernolf
Copy link
Copy Markdown
Contributor Author

ernolf commented May 9, 2026

/backport to stable33

@ernolf ernolf requested a review from szaimen May 9, 2026 01:48
@szaimen szaimen added this to the Nextcloud 34 milestone May 9, 2026
@szaimen szaimen added bug 3. to review Waiting for reviews labels May 9, 2026
@szaimen szaimen requested review from provokateurin and tcitworld May 9, 2026 10:01
Comment thread lib/private/Http/Client/Client.php Outdated
…BROTLI

Signed-off-by: ernolf <raphael.gradenwitz@googlemail.com>
@provokateurin provokateurin enabled auto-merge May 11, 2026 12:15
@provokateurin provokateurin merged commit 94c25e2 into master May 11, 2026
249 of 270 checks passed
@provokateurin provokateurin deleted the ernolf/fix/brotli-detection branch May 11, 2026 18:34
@nextcloud-bot nextcloud-bot mentioned this pull request May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants