Skip to content

Commit 7dd6293

Browse files
committed
Merge branch '4.4' into 5.4
* 4.4: Remove extra space in NotificationEmail Fix the usage of the Valid constraints in array-based forms [DI] fix `ServiceSubscriberTrait` bug where parent has `__call()` [HttpClient] Fix reading proxy settings from dotenv when curl is used [Process] Don't return executable directories in PhpExecutableFinder Center icons vertically in trace list
2 parents fab8479 + a9ccd32 commit 7dd6293

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

CurlHttpClient.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ public function request(string $method, string $url, array $options = []): Respo
9595
$scheme = $url['scheme'];
9696
$authority = $url['authority'];
9797
$host = parse_url($authority, \PHP_URL_HOST);
98+
$proxy = $options['proxy']
99+
?? ('https:' === $url['scheme'] ? $_SERVER['https_proxy'] ?? $_SERVER['HTTPS_PROXY'] ?? null : null)
100+
// Ignore HTTP_PROXY except on the CLI to work around httpoxy set of vulnerabilities
101+
?? $_SERVER['http_proxy'] ?? (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? $_SERVER['HTTP_PROXY'] ?? null : null) ?? $_SERVER['all_proxy'] ?? $_SERVER['ALL_PROXY'] ?? null;
98102
$url = implode('', $url);
99103

100104
if (!isset($options['normalized_headers']['user-agent'])) {
@@ -110,7 +114,7 @@ public function request(string $method, string $url, array $options = []): Respo
110114
\CURLOPT_MAXREDIRS => 0 < $options['max_redirects'] ? $options['max_redirects'] : 0,
111115
\CURLOPT_COOKIEFILE => '', // Keep track of cookies during redirects
112116
\CURLOPT_TIMEOUT => 0,
113-
\CURLOPT_PROXY => $options['proxy'],
117+
\CURLOPT_PROXY => $proxy,
114118
\CURLOPT_NOPROXY => $options['no_proxy'] ?? $_SERVER['no_proxy'] ?? $_SERVER['NO_PROXY'] ?? '',
115119
\CURLOPT_SSL_VERIFYPEER => $options['verify_peer'],
116120
\CURLOPT_SSL_VERIFYHOST => $options['verify_host'] ? 2 : 0,
@@ -409,8 +413,15 @@ private static function createRedirectResolver(array $options, string $host): \C
409413
}
410414

411415
$url = self::parseUrl(curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL));
416+
$url = self::resolveUrl($location, $url);
412417

413-
return implode('', self::resolveUrl($location, $url));
418+
curl_setopt($ch, \CURLOPT_PROXY, $options['proxy']
419+
?? ('https:' === $url['scheme'] ? $_SERVER['https_proxy'] ?? $_SERVER['HTTPS_PROXY'] ?? null : null)
420+
// Ignore HTTP_PROXY except on the CLI to work around httpoxy set of vulnerabilities
421+
?? $_SERVER['http_proxy'] ?? (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? $_SERVER['HTTP_PROXY'] ?? null : null) ?? $_SERVER['all_proxy'] ?? $_SERVER['ALL_PROXY'] ?? null
422+
);
423+
424+
return implode('', $url);
414425
};
415426
}
416427

0 commit comments

Comments
 (0)