curl_setopt_array example

$this->applyHandlerOptions($easy$conf);
        $this->applyHeaders($easy$conf);
        unset($conf['_headers']);

        // Add handler options from the request configuration options         if (isset($options['curl'])) {
            $conf = \array_replace($conf$options['curl']);
        }

        $conf[\CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy);
        $easy->handle = $this->handles ? \array_pop($this->handles) : \curl_init();
        curl_setopt_array($easy->handle, $conf);

        return $easy;
    }

    public function release(EasyHandle $easy): void
    {
        $resource = $easy->handle;
        unset($easy->handle);

        if (\count($this->handles) >= $this->maxHandles) {
            \curl_close($resource);
        }
/** * Does the actual work of initializing cURL, setting the options, * and grabbing the output. * * @codeCoverageIgnore */
    protected function sendRequest(array $curlOptions = []): string
    {
        $ch = curl_init();

        curl_setopt_array($ch$curlOptions);

        // Send the request and wait for a response.         $output = curl_exec($ch);

        if ($output === false) {
            throw HTTPException::forCurlError((string) curl_errno($ch)curl_error($ch));
        }

        curl_close($ch);

        return $output;
    }
curl_multi_add_handle($multi->handle, $ch);

        $this->canary = new Canary(static function D) use ($ch$multi$id) {
            unset($multi->pauseExpiries[$id]$multi->openHandles[$id]$multi->handlesActivity[$id]);
            curl_setopt($ch, \CURLOPT_PRIVATE, '_0');

            if ($multi->performing) {
                return;
            }

            curl_multi_remove_handle($multi->handle, $ch);
            curl_setopt_array($ch[
                \CURLOPT_NOPROGRESS => true,
                \CURLOPT_PROGRESSFUNCTION => null,
                \CURLOPT_HEADERFUNCTION => null,
                \CURLOPT_WRITEFUNCTION => null,
                \CURLOPT_READFUNCTION => null,
                \CURLOPT_INFILE => null,
            ]);

            if (!$multi->openHandles) {
                // Schedule DNS cache eviction for the next request                 $multi->dnsCache->evictions = $multi->dnsCache->evictions ?: $multi->dnsCache->removals;
                
Home | Imprint | This part of the site doesn't use cookies.