[php-src] PR #25048: Fix GH-8832: Honor protocol_version for proxy CONNECT requests
| From: | glbessa | Date: | Fri, 30 Oct 2026 06:42:03 +0000 |
| Subject: | [php-src] PR #25048: Fix GH-8832: Honor protocol_version for proxy CONNECT requests | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40079@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25048
Author: glbessa
Closes GH-8832
The http stream wrapper always sends the
CONNECT request used to tunnel HTTPS through a
proxy as HTTP/1.0, regardless of the protocol_version context option. Proxies that only
accept HTTP/1.1 (e.g. Envoy, as in the issue) answer with 426 Upgrade Required, making
file_get_contents() over HTTPS through such a proxy impossible.
This makes the CONNECT request honor the existing protocol_version context
option, and sends the Host header (the target authority) that HTTP/1.1 requires:
```
CONNECT www.php.net:443 HTTP/1.1
Host: www.php.net:443
```
When the option is not set, nothing changes: CONNECT is still sent as HTTP/1.0, without
Host.
Notes:
- I reused protocol_version rather than adding a new option such as
proxy_protocol_version, since users setting it most likely expect it to apply to the
whole exchange, and it keeps the API surface unchanged. Happy to switch if a separate option is
preferred.
- Handling 426 Upgrade Required automatically (as discussed in the issue) does not help
here, since the proxy in the report closes the connection and sends no Upgrade header.
- The version is formatted exactly like the main request line (zval_get_double() +
%.1F), so both lines always agree.
- Added a test based on the existing http_proxy_ssl_connect_0x.phpt tests; the HTTP/1.0
default is already covered by http_proxy_ssl_connect_01.phpt. Added an UPGRADING entry
under "Changed Functions".
🤖 Generated with [Claude Code](https://claude.com/claude-code)