WordPress / WordPress/Requests
Allow the cURL transport to use native HTTP protocol negotiation
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 500
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 5
Description
Is your feature request related to a problem?
Requests defaults protocol_version to HTTP/1.1 and the cURL transport therefore explicitly sets:
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1
This prevents libcurl from using its native HTTP protocol negotiation, even when both libcurl and the server support HTTP/2 or newer protocols.
This is related to #381 and PR #918, but is intentionally narrower. Instead of adding explicit HTTP/2 / HTTP/3 support, this issue is about allowing capable transports to choose the protocol themselves.
Describe the solution you'd like
Add a way to request transport-native protocol negotiation, for example with null or "auto".
Conceptually:
1.0 -> force HTTP/1.0
1.1 -> force HTTP/1.1
auto -> let the transport decide
For cURL, auto would mean not setting CURLOPT_HTTP_VERSION and letting libcurl negotiate the protocol.
For fsockopen, Requests could continue using the HTTP/1.x version it supports.
Describe alternatives you've considered
PR #918 adds explicit 2.0 and 3.0 protocol versions, but that also introduces questions around transport capabilities, HTTP/3 and testing infrastructure.
Another workaround is changing the cURL handle through hooks, but that requires downstream applications to know that Requests otherwise forces HTTP/1.1.
Additional context
This came up while investigating HTTP/2 support in WP-CLI.
A native-negotiation mode could be tested using CURLINFO_HTTP_VERSION against an HTTP/2-capable test server, while preserving HTTP/1.1 fallback when HTTP/2 is unavailable.
The main design question is whether protocol_version should always dictate the protocol for every transport, or whether protocol selection can remain a transport capability when the caller does not explicitly request a version.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing protocol_version handling in the cURL and fsockopen transports, including how CURLOPT_HTTP_VERSION is set. Resolve whether an auto or null mode should leave protocol selection to cURL while preserving HTTP/1.x behavior for fsockopen. Validate the result with CURLINFO_HTTP_VERSION against an HTTP/2-capable test server and confirm HTTP/1.1 fallback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, networking
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100