public function proceed(): void
    {
        if (empty($this->queue)) {
            return;
        }

        if (!$this->curlm) {
            $this->initMultiCurlHandle();
        }

        $this->initQueue();
        $exception = null;
        do {
            // Start processing each handler in the stack
            $mrc = curl_multi_exec($this->curlm, $stillRunning);
        } while (CURLM_CALL_MULTI_PERFORM === $mrc);

        while ($info = curl_multi_info_read($this->curlm)) {
            // handle any completed requests
            if (CURLMSG_DONE !== $info['msg']) {
                continue;
            }

            $handled = false;

            /** @var RequestInterface $request */
            /** @var ParameterBag $options */
            /** @var ResponseBuilder $responseBuilder */
            foreach ($this->queue as $i => list($request, $options, $curl, $responseBuilder)) {
                // Try to find the correct handle from the queue.
                if ($curl !== $info['handle']) {
                    continue;
                }

                $handled = true;
                $response = null;
                try {
                    $this->parseError($request, $info['result'], $curl);
                    $response = $responseBuilder->getResponse();
                    if ($options->get('expose_curl_info', false)) {
                        $response = $response->withHeader('__curl_info', json_encode(curl_getinfo($curl)));
                    }
                } catch (\Throwable $e) {
                    if (null === $exception) {
                        $exception = $e;
                    }
                }

                // remove from queue
                curl_multi_remove_handle($this->curlm, $curl);
                $this->releaseHandle($curl);
                unset($this->queue[$i]);

                // callback
                \call_user_func($options->get('callback'), $request, $response, $exception);
                $exception = null;
            }

            if (!$handled) {
                // It must be a pushed response.
                $this->handlePushedResponse($info['handle']);
            }
        }

        $this->cleanup();
    }
public function proceed(): void
    {
        if (empty($this->queue)) {
            return;
        }

        if (!$this->curlm) {
            $this->initMultiCurlHandle();
        }

        $this->initQueue();
        $exception = null;
        do {
            // Start processing each handler in the stack
            $mrc = curl_multi_exec($this->curlm, $stillRunning);
        } while (CURLM_CALL_MULTI_PERFORM === $mrc);

        while ($info = curl_multi_info_read($this->curlm)) {
            // handle any completed requests
            if (CURLMSG_DONE !== $info['msg']) {
                continue;
            }

            $handled = false;

            /** @var RequestInterface $request */
            /** @var ParameterBag $options */
            /** @var ResponseBuilder $responseBuilder */
            foreach ($this->queue as $i => list($request, $options, $curl, $responseBuilder)) {
                // Try to find the correct handle from the queue.
                if ($curl !== $info['handle']) {
                    continue;
                }

                $handled = true;
                $response = null;
                try {
                    $this->parseError($request, $info['result'], $curl);
                    $response = $responseBuilder->getResponse();
                    if ($options->get('expose_curl_info', false)) {
                        $response = $response->withHeader('__curl_info', json_encode(curl_getinfo($curl)));
                    }
                } catch (\Throwable $e) {
                    if (null === $exception) {
                        $exception = $e;
                    }
                }

                // remove from queue
                curl_multi_remove_handle($this->curlm, $curl);
                $this->releaseHandle($curl);
                unset($this->queue[$i]);

                // callback
                \call_user_func($options->get('callback'), $request, $response, $exception);
                $exception = null;
            }

            if (!$handled) {
                // It must be a pushed response.
                $this->handlePushedResponse($info['handle']);
            }
        }

        $this->cleanup();
    }
public function proceed ( ) : void { if ( empty ( $ this -> queue ) ) { return ; } if ( ! $ this -> curlm ) { $ this -> initMultiCurlHandle ( ) ; } $ this -> initQueue ( ) ; $ exception = null ; do { // Start processing each handler in the stack $ mrc = curl_multi_exec ( $ this -> curlm , $ stillRunning ) ; } while ( CURLM_CALL_MULTI_PERFORM === $ mrc ) ; while ( $ info = curl_multi_info_read ( $ this -> curlm ) ) { // handle any completed requests if ( CURLMSG_DONE !== $ info [ 'msg' ] ) { continue ; } $ handled = false ; /** @var RequestInterface $request */ /** @var ParameterBag $options */ /** @var ResponseBuilder $responseBuilder */ foreach ( $ this -> queue as $ i => list ( $ request , $ options , $ curl , $ responseBuilder ) ) { // Try to find the correct handle from the queue. if ( $ curl !== $ info [ 'handle' ] ) { continue ; } $ handled = true ; $ response = null ; try { $ this -> parseError ( $ request , $ info [ 'result' ] , $ curl ) ; $ response = $ responseBuilder -> getResponse ( ) ; if ( $ options -> get ( 'expose_curl_info' , false ) ) { $ response = $ response -> withHeader ( '__curl_info' , json_encode ( curl_getinfo ( $ curl ) ) ) ; } } catch ( \ Throwable $ e ) { if ( null === $ exception ) { $ exception = $ e ; } } // remove from queue curl_multi_remove_handle ( $ this -> curlm , $ curl ) ; $ this -> releaseHandle ( $ curl ) ; unset ( $ this -> queue [ $ i ] ) ; // callback \ call_user_func ( $ options -> get ( 'callback' ) , $ request , $ response , $ exception ) ; $ exception = null ; } if ( ! $ handled ) { // It must be a pushed response. $ this -> handlePushedResponse ( $ info [ 'handle' ] ) ; } } $ this -> cleanup ( ) ; }
See if any connection is ready to be processed.

This is a non-blocking function call.

@throws ClientException if we fail to initialized cUrl
See if any connection is ready to be processed .