curl_setopt

Supported Versions: PHP 4 >= 4.0.2, PHP 5, PHP 7, PHP 8
Set an option for a cURL transfer
<?php curl_setopt(CurlHandle $handle, int $option, mixed $value): bool
<?php             $bodyHandle = @fopen('php://temp/maxmemory:524288', 'w+b');

        }



        curl_setopt($curlHandle, CURLOPT_URL, $url);

        curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, false);

        curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);

        curl_setopt($curlHandle, CURLOPT_TIMEOUT, max((int) ini_get("default_socket_timeout"), 300));
<?php         }



        curl_setopt($curlHandle, CURLOPT_URL, $url);

        curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, false);

        curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);

        curl_setopt($curlHandle, CURLOPT_TIMEOUT, max((int) ini_get("default_socket_timeout"), 300));

        curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);
<?php         curl_setopt($curlHandle, CURLOPT_URL, $url);

        curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, false);

        curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);

        curl_setopt($curlHandle, CURLOPT_TIMEOUT, max((int) ini_get("default_socket_timeout"), 300));

        curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);

        curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);
<?php         curl_setopt($curlHandle, CURLOPT_URL, $url);

        curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, false);

        curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);

        curl_setopt($curlHandle, CURLOPT_TIMEOUT, max((int) ini_get("default_socket_timeout"), 300));

        curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);

        curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);

        curl_setopt($curlHandle, CURLOPT_ENCODING, ""); // let cURL set the Accept-Encoding header to what it supports
<?php         curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, false);

        curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);

        curl_setopt($curlHandle, CURLOPT_TIMEOUT, max((int) ini_get("default_socket_timeout"), 300));

        curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);

        curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);

        curl_setopt($curlHandle, CURLOPT_ENCODING, ""); // let cURL set the Accept-Encoding header to what it supports

        curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
<?php         curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);

        curl_setopt($curlHandle, CURLOPT_TIMEOUT, max((int) ini_get("default_socket_timeout"), 300));

        curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);

        curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);

        curl_setopt($curlHandle, CURLOPT_ENCODING, ""); // let cURL set the Accept-Encoding header to what it supports

        curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
<?php         curl_setopt($curlHandle, CURLOPT_TIMEOUT, max((int) ini_get("default_socket_timeout"), 300));

        curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);

        curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);

        curl_setopt($curlHandle, CURLOPT_ENCODING, ""); // let cURL set the Accept-Encoding header to what it supports

        curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);



        if (function_exists('curl_share_init')) {
<?php         curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);

        curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);

        curl_setopt($curlHandle, CURLOPT_ENCODING, ""); // let cURL set the Accept-Encoding header to what it supports

        curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);



        if (function_exists('curl_share_init')) {

            curl_setopt($curlHandle, CURLOPT_SHARE, $this->shareHandle);
<?php         curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);



        if (function_exists('curl_share_init')) {

            curl_setopt($curlHandle, CURLOPT_SHARE, $this->shareHandle);

        }



        if (!isset($options['http']['header'])) {
<?php         $version = curl_version();

        $features = $version['features'];

        if (0 === strpos($url, 'https://') && \defined('CURL_VERSION_HTTP2') && \defined('CURL_HTTP_VERSION_2_0') && (CURL_VERSION_HTTP2 & $features)) {

            curl_setopt($curlHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);

        }



        $options['http']['header'] = $this->authHelper->addAuthenticationHeader($options['http']['header'], $origin, $url);
<?php             foreach ($curlOptions as $name => $curlOption) {

                if (isset($options[$type][$name])) {

                    if ($type === 'ssl' && $name === 'verify_peer_name') {

                        curl_setopt($curlHandle, $curlOption, $options[$type][$name] === true ? 2 : $options[$type][$name]);

                    } else {

                        curl_setopt($curlHandle, $curlOption, $options[$type][$name]);

                    }
<?php                     if ($type === 'ssl' && $name === 'verify_peer_name') {

                        curl_setopt($curlHandle, $curlOption, $options[$type][$name] === true ? 2 : $options[$type][$name]);

                    } else {

                        curl_setopt($curlHandle, $curlOption, $options[$type][$name]);

                    }

                }

            }
<?php         $proxy = $this->proxyManager->getProxyForRequest($url);

        curl_setopt($curlHandle, CURLOPT_PROXY, $proxy->getUrl());
<?php                 throw new TransportException('Connecting to a secure proxy using curl is not supported on PHP versions below 7.3.0.');

            }

            if (!empty($options['ssl']['cafile'])) {

                curl_setopt($curlHandle, CURLOPT_PROXY_CAINFO, $options['ssl']['cafile']);

            }

            if (!empty($options['ssl']['capath'])) {

                curl_setopt($curlHandle, CURLOPT_PROXY_CAPATH, $options['ssl']['capath']);
<?php                 curl_setopt($curlHandle, CURLOPT_PROXY_CAINFO, $options['ssl']['cafile']);

            }

            if (!empty($options['ssl']['capath'])) {

                curl_setopt($curlHandle, CURLOPT_PROXY_CAPATH, $options['ssl']['capath']);

            }

        }