guzzle / guzzle

Guzzle, an extensible PHP HTTP client

Home Page:https://docs.guzzlephp.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NO_PROXY confusion on CLI

croensch opened this issue · comments

Guzzle version(s) affected: 7.4.4
PHP version: 8.0.20
cURL version: 7.68.0

Description
When PHP is run as CLI, the cURL library will automatically pick up no_proxy/NO_PROXY and https_proxy/... from the environment. Unlike PHP-FPM this is often not isolated from the host environment. In theory this all can be overwritten by Guzzle per instance. But because Guzzle checks the target domain itself here. It just won't override proxy, but the cURL library will still use the real environments proxy and no_proxy.

How to reproduce

export https_proxy=http://localhost:9124
export no_proxy=.mit.edu
php test.php
$client->request('GET', 'https://foo.com/', [
    'proxy' => [
        'https' => 'http://localhost:9124',
        'no' => ['foo.com']
    ]
]);

Possible Solution
The guzzle config should be imploded and passed as \CURLOPT_NOPROXY to be consistent in all environments.

Additional context

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 2 weeks if no further activity occurs. Thank you for your contributions.