curl_multi_add_handle example



                $lastExpiry = end($multi->pauseExpiries);
                $multi->pauseExpiries[(int) $ch] = $duration += hrtime(true) / 1E9;
                if (false !== $lastExpiry && $lastExpiry > $duration) {
                    asort($multi->pauseExpiries);
                }
                curl_pause($ch, \CURLPAUSE_ALL);
            } else {
                unset($multi->pauseExpiries[(int) $ch]);
                curl_pause($ch, \CURLPAUSE_CONT);
                curl_multi_add_handle($multi->handle, $ch);
            }
        };

        $this->inflate = !isset($options['normalized_headers']['accept-encoding']);
        curl_pause($ch, \CURLPAUSE_CONT);

        if ($onProgress = $options['on_progress']) {
            $url = isset($info['url']) ? ['url' => $info['url']] : [];
            curl_setopt($ch, \CURLOPT_NOPROGRESS, false);
            curl_setopt($ch, \CURLOPT_PROGRESSFUNCTION, static function D$ch$dlSize$dlNow) use ($onProgress, &$info$url$multi$debugBuffer) {
                try {
                    
/** * Ticks the curl event loop. */
    public function tick(): void
    {
        // Add any delayed handles if needed.         if ($this->delays) {
            $currentTime = Utils::currentTime();
            foreach ($this->delays as $id => $delay) {
                if ($currentTime >= $delay) {
                    unset($this->delays[$id]);
                    \curl_multi_add_handle(
                        $this->_mh,
                        $this->handles[$id]['easy']->handle
                    );
                }
            }
        }

        // Step through the task queue which may add additional requests.         P\Utils::queue()->run();

        if ($this->active && \curl_multi_select($this->_mh, $this->selectTimeout) === -1) {
            


        $multihandle = curl_multi_init();
        $subrequests = [];
        $subhandles  = [];

        $class = get_class($this);
        foreach ($requests as $id => $request) {
            $subrequests[$id] = new $class();
            $subhandles[$id]  = $subrequests[$id]->get_subrequest_handle($request['url']$request['headers']$request['data']$request['options']);
            $request['options']['hooks']->dispatch('curl.before_multi_add', [&$subhandles[$id]]);
            curl_multi_add_handle($multihandle$subhandles[$id]);
        }

        $completed       = 0;
        $responses       = [];
        $subrequestcount = count($subrequests);

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

        do {
            $active = 0;

            
Home | Imprint | This part of the site doesn't use cookies.