1
0
Fork 0

Fix logic (again)

pull/9334/head
johnstevenson 2020-10-25 12:59:01 +00:00
parent 2a913c7a68
commit c99e19db64
2 changed files with 19 additions and 17 deletions

View File

@ -13,6 +13,8 @@
namespace Composer\Exception;
/**
* Specific exception for Composer\Util\HttpDownloader creation.
*
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class NoSslException extends \RuntimeException

View File

@ -75,27 +75,27 @@ final class StreamContextFactory
// Add stream proxy options if there is a proxy
if (!$forCurl) {
$proxy = ProxyManager::getInstance()->getProxyForRequest($url);
$isHttpsRequest = 0 === strpos($url, 'https://');
if ($proxyOptions = $proxy->getContextOptions()) {
$isHttpsRequest = 0 === strpos($url, 'https://');
if ($proxy->isSecure()) {
if (!extension_loaded('openssl')) {
throw new TransportException('You must enable the openssl extension to use a secure proxy.');
if ($proxy->isSecure()) {
if (!extension_loaded('openssl')) {
throw new TransportException('You must enable the openssl extension to use a secure proxy.');
}
if ($isHttpsRequest) {
throw new TransportException('You must enable the curl extension to make https requests through a secure proxy.');
}
} elseif ($isHttpsRequest && !extension_loaded('openssl')) {
throw new TransportException('You must enable the openssl extension to make https requests through a proxy.');
}
if ($isHttpsRequest) {
throw new TransportException('You must enable the curl extension to make https requests through a secure proxy.');
// Header will be a Proxy-Authorization string or not set
if (isset($proxyOptions['http']['header'])) {
$options['http']['header'][] = $proxyOptions['http']['header'];
unset($proxyOptions['http']['header']);
}
} elseif ($isHttpsRequest && !extension_loaded('openssl')) {
throw new TransportException('You must enable the openssl extension to make https requests through a proxy.');
$options = array_replace_recursive($options, $proxyOptions);
}
$proxyOptions = $proxy->getContextOptions();
// Header will be a Proxy-Authorization string or not set
if (isset($proxyOptions['http']['header'])) {
$options['http']['header'][] = $proxyOptions['http']['header'];
unset($proxyOptions['http']['header']);
}
$options = array_replace_recursive($options, $proxyOptions);
}
if (defined('HHVM_VERSION')) {