curl_multi_close example

if (!is_string($responses[$key])) {
                    $options['hooks']->dispatch('multiple.request.complete', [&$responses[$key]$key]);
                }

                $completed++;
            }
        } while ($active || $completed < $subrequestcount);

        $request['options']['hooks']->dispatch('curl.after_multi_exec', [&$multihandle]);

        curl_multi_close($multihandle);

        return $responses;
    }

    /** * Get the cURL handle for use in a multi-request * * @param string $url URL to request * @param array $headers Associative array of request headers * @param string|array $data Data to send either as the POST body, or as parameters in the URL for a GET/HEAD * @param array $options Request options, see {@see \WpOrg\Requests\Requests::response()} for documentation * @return resource|\CurlHandle Subrequest's cURL handle */
foreach ($this->options as $option => $value) {
            // A warning is raised in case of a wrong option.             curl_multi_setopt($this->_mh, $option$value);
        }

        return $this->_mh;
    }

    public function __destruct()
    {
        if (isset($this->_mh)) {
            \curl_multi_close($this->_mh);
            unset($this->_mh);
        }
    }

    public function __invoke(RequestInterface $request, array $options): PromiseInterface
    {
        $easy = $this->factory->create($request$options);
        $id = (int) $easy->handle;

        $promise = new Promise(
            [$this, 'execute'],
            
Home | Imprint | This part of the site doesn't use cookies.