Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. RequestProxy.php

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\Http

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal