Skip to content

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

Open
ernolf wants to merge 1 commit intomasterfrom
ernolf/fix/brotli-detection
Open

fix(http-client): detect brotli support via libcurl, not PHP extension#60262
ernolf wants to merge 1 commit intomasterfrom
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants