function RequestProxy::getCurlOptions
Returns an array of curl proxy options
Parameters
array<string, string|int> $sslOptions:
Return value
array<int, string|int>
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ Http/ RequestProxy.php, line 74
Class
- RequestProxy
- @internal @author John Stevenson <john-stevenson@blueyonder.co.uk>
Namespace
Composer\Util\HttpCode
public function getCurlOptions(array $sslOptions) : array {
if ($this->isSecure() && !$this->supportsSecureProxy()) {
throw new TransportException('Cannot use an HTTPS proxy. PHP >= 7.3 and cUrl >= 7.52.0 are required.');
}
// Always set a proxy url, even an empty value, because it tells curl
// to ignore proxy environment variables
$options = [
CURLOPT_PROXY => (string) $this->url,
];
// If using a proxy, tell curl to ignore no_proxy environment variables
if ($this->url !== null) {
$options[CURLOPT_NOPROXY] = '';
}
// Set any authorization
if ($this->auth !== null) {
$options[CURLOPT_PROXYAUTH] = CURLAUTH_BASIC;
$options[CURLOPT_PROXYUSERPWD] = $this->auth;
}
if ($this->isSecure()) {
if (isset($sslOptions['cafile'])) {
$options[CURLOPT_PROXY_CAINFO] = $sslOptions['cafile'];
}
if (isset($sslOptions['capath'])) {
$options[CURLOPT_PROXY_CAPATH] = $sslOptions['capath'];
}
}
return $options;
}