Skip to content

Commit 09a8120

Browse files
bohanyangnicolas-grekas
authored andcommitted
[HttpClient] Fix using https with proxies
1 parent 00a6122 commit 09a8120

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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
return new NativeResponse($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
return implode('', $url);
418418
};
419419
}
420420

421-
private static function configureHeadersAndProxy($context, string $host, array $requestHeaders, ?array $proxy, array $noProxy)
421+
private static function configureHeadersAndProxy($context, string $host, array $requestHeaders, ?array $proxy, array $noProxy, bool $isSsl)
422422
{
423423
if (null === $proxy) {
424424
return stream_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)