php / php/php-src

Support "protocol_version" stream context option for proxy connections

Open
#8,832 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Category: Streams Feature Status: Verified
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

Hello. We have protocol_version option for talking with remote host using specified HTTP protocol version. However, HTTP connection to proxy always goes with HTTP/1.0 which upsets my proxy server.

Example:

<?php
$ctx = stream_context_create(
  ['http' => ['proxy' => 'tcp://corporate-proxy.example:3128']]
);
echo file_get_contents("https://getcomposer.org/versions", false, $ctx);

Result:

Warning: file_get_contents(): SSL: Connection reset by peer in a.php on line 5

Warning: file_get_contents(https://getcomposer.org/versions):
  Failed to open stream: Cannot connect to HTTPS server through proxy in a.php on line 5

Actual request as seen by wireshark:

CONNECT getcomposer.org:443 HTTP/1.0

HTTP/1.1 426 Upgrade Required
date: Mon, 20 Jun 2022 10:23:30 GMT
server: envoy
connection: close
content-length: 0

My proxy server supports only HTTP/1.1. So it's would be very handy to have an option for configuring http protocol version for proxy connections.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with PHP's HTTP stream wrapper and the proxy CONNECT request path, comparing them with existing protocol_version handling for direct requests. Verify that the option applies to proxy connections and exercise the HTTPS-through-proxy example, confirming the CONNECT request uses the configured HTTP version.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.