Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitabe0eca

Browse files
bug#38368 [HttpClient] Fix using https with proxies (bohanyang)
This PR was squashed before being merged into the 4.4 branch.Discussion----------[HttpClient] Fix using https with proxies| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | yes| New feature? | no| Deprecations? | no| License | MIT| Doc PR | -According to my test, when `request_fulluri` is set to true,the host appears in the URL will be the Host header,even if the Host header is set in the context http header.Since HttpClient has its own DNS cache, the host inside the URL is usually an IP address.So this can break many things.```{ "args": {}, "headers": { "Accept": "*/*", "Accept-Encoding": "gzip", "Host": "3.211.1.78", "User-Agent": "Symfony HttpClient/Native", "X-Amzn-Trace-Id": "Root=1-5f75a59e-62c8c81e4490e09c700d6180" }, "origin": "xxx.xxx.xxx.xxx", "url": "https://3.211.1.78/get"}* Hostname was NOT found in DNS cache* Added httpbin.org:0:3.211.1.78 to DNS cache* Establish HTTP proxy tunnel to tcp://10.22.22.21:7777> GEThttps://3.211.1.78/get HTTP/1.1Accept: */*Accept-Encoding: gzipHost: httpbin.orgUser-Agent: Symfony HttpClient/Native< HTTP/1.1 200 OK< Date: Thu, 01 Oct 2020 09:47:10 GMT< Content-Type: application/json< Content-Length: 300< Connection: close< Server: gunicorn/19.9.0< Access-Control-Allow-Origin: *< Access-Control-Allow-Credentials: true<```I've also found thisguzzle/guzzle#791We can also create an option to make it customizable.Commits-------7e0cd4e [HttpClient] Fix using https with proxies
2 parentsdadce4b +7e0cd4e commitabe0eca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎src/Symfony/Component/HttpClient/NativeHttpClient.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function request(string $method, string $url, array $options = []): Respo
225225

226226
$resolveRedirect =self::createRedirectResolver($options,$host,$proxy,$noProxy,$info,$onProgress);
227227
$context =stream_context_create($context, ['notification' =>$notification]);
228-
self::configureHeadersAndProxy($context,$host,$options['headers'],$proxy,$noProxy);
228+
self::configureHeadersAndProxy($context,$host,$options['headers'],$proxy,$noProxy,'https:' ===$url['scheme']);
229229

230230
returnnewNativeResponse($this->multi,$context,implode('',$url),$options,$info,$resolveRedirect,$onProgress,$this->logger);
231231
}
@@ -411,14 +411,14 @@ private static function createRedirectResolver(array $options, string $host, ?ar
411411
// Authorization and Cookie headers MUST NOT follow except for the initial host name
412412
$requestHeaders =$redirectHeaders['host'] ===$host ?$redirectHeaders['with_auth'] :$redirectHeaders['no_auth'];
413413
$requestHeaders[] ='Host:'.$host.$port;
414-
self::configureHeadersAndProxy($context,$host,$requestHeaders,$proxy,$noProxy);
414+
self::configureHeadersAndProxy($context,$host,$requestHeaders,$proxy,$noProxy,'https:' ===$url['scheme']);
415415
}
416416

417417
returnimplode('',$url);
418418
};
419419
}
420420

421-
privatestaticfunctionconfigureHeadersAndProxy($context,string$host,array$requestHeaders, ?array$proxy,array$noProxy)
421+
privatestaticfunctionconfigureHeadersAndProxy($context,string$host,array$requestHeaders, ?array$proxy,array$noProxy,bool$isSsl)
422422
{
423423
if (null ===$proxy) {
424424
returnstream_context_set_option($context,'http','header',$requestHeaders);
@@ -435,7 +435,7 @@ private static function configureHeadersAndProxy($context, string $host, array $
435435
}
436436

437437
stream_context_set_option($context,'http','proxy',$proxy['url']);
438-
stream_context_set_option($context,'http','request_fulluri',true);
438+
stream_context_set_option($context,'http','request_fulluri',!$isSsl);
439439

440440
if (null !==$proxy['auth']) {
441441
$requestHeaders[] ='Proxy-Authorization:'.$proxy['auth'];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp