Skip to content

Conversation

@joshtrichards
Copy link
Member

Summary

This is a mixture of a fix and an enhancement.

In the HTTP client, previously we forced Accept-Encoding 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). In others, the specific server/client combo will simply choose something "better".

Notes:

Checklist

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>
@joshtrichards joshtrichards added this to the Nextcloud 32 milestone Jun 19, 2025
@joshtrichards joshtrichards requested a review from a team as a code owner June 19, 2025 14:06
@joshtrichards joshtrichards requested review from nfebe and skjnldsv and removed request for a team June 19, 2025 14:06
@joshtrichards joshtrichards added the 3. to review Waiting for reviews label Jun 19, 2025
This was referenced Aug 22, 2025
This was referenced Sep 2, 2025
This was referenced Sep 25, 2025
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
@nextcloud-bot nextcloud-bot mentioned this pull request Jan 7, 2026
Copy link
Contributor

@ernolf ernolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. libcurl advertises br
  2. the server selects Content-Encoding: br
  3. PHP/Guzzle cannot decode it
  4. 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.

@nextcloud-bot nextcloud-bot mentioned this pull request Jan 9, 2026
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.

4 participants