Skip to content

fix(http-client): guard HTTP/2 defaults against unsupported libcurl builds#59662

Open
joshtrichards wants to merge 7 commits intomasterfrom
jtr/refactor-http-client
Open

fix(http-client): guard HTTP/2 defaults against unsupported libcurl builds#59662
joshtrichards wants to merge 7 commits intomasterfrom
jtr/refactor-http-client

Conversation

@joshtrichards
Copy link
Copy Markdown
Member

@joshtrichards joshtrichards commented Apr 15, 2026

Summary

Only enable HTTP/2 defaults when local libcurl supports HTTP/2. Also refactors buildRequestOptions() into smaller helpers.

Motivation

Improve readability of the request option setup and fix #58528, where HTTP/2 defaults can break setups with libcurl builds that do not support HTTP/2.

What changed

  • extract request option setup into smaller private helpers
  • simplify proxy, header, redirect, and legacy option handling
  • only set RequestOptions::VERSION and curl HTTP/2 options when libcurl supports HTTP/2
  • update ClientTest to cover both HTTP/2-supported and unsupported cases deterministically

Related

Notes

Checklist

AI (if applicable)

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

Signed-off-by: Josh <josh.t.richards@gmail.com>
Fixes #58528 

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards added bug ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) labels Apr 15, 2026
@joshtrichards joshtrichards marked this pull request as ready for review April 15, 2026 22:26
@joshtrichards joshtrichards requested a review from a team as a code owner April 15, 2026 22:26
@joshtrichards joshtrichards requested review from icewind1991, leftybournes and salmart-dev and removed request for a team April 15, 2026 22:26
@joshtrichards joshtrichards added the 3. to review Waiting for reviews label Apr 15, 2026
@joshtrichards joshtrichards added this to the Nextcloud 34 milestone Apr 15, 2026
@joshtrichards
Copy link
Copy Markdown
Member Author

/backport to stable33

Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards changed the title fix(http-client): refactor request option building and guard HTTP/2 defaults fix(http-client): guard HTTP/2 defaults against unsupported libcurl builds Apr 15, 2026
Copy link
Copy Markdown
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.

Thanks for the effort. I have to decline this PR, though I'm happy to discuss if others see this differently.

The removal of the HTTP/2 guard in #55433 was a deliberate decision:
HTTP/2 support has been present in every PHP-supported libcurl version for years:

CURL_HTTP_VERSION_2_0 and CURL_VERSION_HTTP2 (the feature flag) were both introduced in libcurl 7.33.0 (October 2013) — see commits curl/curl@698e3bd and curl/curl@b77997e, both from September 2013. CURL_HTTP_VERSION_2TLS followed later in 7.47.0 (January 2016).

A system where supportsHttp2() returns true — meaning CURL_VERSION_HTTP2 is set in the features bitmask — but CURL_HTTP_VERSION_2TLS is not defined, would require a libcurl build from the 7.33.0–7.46.x range. The newest of those (7.46.0) was released on December 2, 2015 — making it at minimum a 10-year-old build. The defined('CURL_HTTP_VERSION_2TLS') check on a PHP constant that comes from the libcurl headers at PHP compile time is designed here as a runtime guard, but it targets a scenario that is purely theoretical in any real-world deployment today. This complicates the logic without any practical benefit.

Any libcurl build old enough to lack CURL_HTTP_VERSION_2TLS predates the very first Nextcloud release (September 2016). Running Nextcloud against such a build means running against a library with years of unpatched CVEs — including TLS and HTTP/2 vulnerabilities. Silently falling back to HTTP/1.1 in that scenario does not make the setup safer; it obscures a serious underlying problem that the server operator needs to fix. A hard failure with a clear error is, in my view, the correct behavior.

What this PR does is reverse that decision by silently degrading to HTTP/1.1 for a vanishingly small group of users with outdated builds. Instead of those few users being prompted to fix their environment, the server permanently carries the complexity — and the degradation becomes invisible.

The correct response to #58528 is, from my perspective, documentation or a clear error message pointing users to upgrade their libcurl build — not a runtime guard that rewards neglected setups.

The refactoring bundled into this PR makes it harder to review the actual fix in isolation, and it's not something I'd want merged separately either — but I acknowledge that's a matter of taste.


ernolf

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 backport-request bug ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP client issue with libcurl without HTTP/2 support

2 participants