Inheritance: implements GuzzleHttp\Handler\CurlFactoryInterface
 /**
  * {@inheritdoc}
  */
 public function release(EasyHandle $easy)
 {
     if (!is_null($easy->response)) {
         $easy->response->curlInfo = curl_getinfo($easy->handle);
     }
     return parent::release($easy);
 }
Exemplo n.º 2
0
 public function __invoke(RequestInterface $request, array $options)
 {
     if (isset($options[RequestOptions::DELAY])) {
         usleep($options[RequestOptions::DELAY] * 1000);
     }
     $easy = $this->factory->create($request, $options);
     curl_exec($easy->handle);
     $easy->errno = curl_errno($easy->handle);
     return CurlFactory::finish($this, $easy, $this->factory);
 }
Exemplo n.º 3
0
 private function processMessages()
 {
     while ($done = curl_multi_info_read($this->_mh)) {
         $id = (int) $done['handle'];
         curl_multi_remove_handle($this->_mh, $done['handle']);
         if (!isset($this->handles[$id])) {
             // Probably was cancelled.
             continue;
         }
         $entry = $this->handles[$id];
         unset($this->handles[$id], $this->delays[$id]);
         $entry['easy']->errno = $done['result'];
         $entry['deferred']->resolve(CurlFactory::finish($this, $entry['easy'], $this->factory));
     }
 }
 public function testDoesNotRewindUnseekableBody()
 {
     $body = Psr7\stream_for(str_repeat('x', 1024 * 1024 * 2));
     $body->seek(1024 * 1024);
     $body = new Psr7\NoSeekStream($body);
     $this->assertSame(1024 * 1024, $body->tell());
     $req = new Psr7\Request('POST', 'https://www.example.com', ['Content-Length' => 1024 * 1024], $body);
     $factory = new CurlFactory(1);
     $factory->create($req, []);
     $this->assertSame(1024 * 1024, $body->tell());
 }
Exemplo n.º 5
0
 private function processHttpMessages()
 {
     $clean = true;
     while ($done = curl_multi_info_read($this->multiHandle)) {
         $id = (int) $done['handle'];
         curl_multi_remove_handle($this->multiHandle, $done['handle']);
         if (!isset($this->httpHandles[$id])) {
             // Probably was cancelled.
             continue;
         }
         $entry = $this->httpHandles[$id];
         unset($this->httpHandles[$id], $this->delays[$id]);
         $entry['easy']->errno = $done['result'];
         /** @var Promise $deferred */
         $deferred = $entry['promise'];
         /** @var CurlFactoryInterface $factory */
         $factory = $this->factory[self::TYPE_HTTP];
         $deferred->resolve(CurlFactory::finish($this, $entry['easy'], $factory));
         $clean = false;
     }
     if (!$clean) {
         \GuzzleHttp\Promise\queue()->run();
         return true;
     }
     return false;
 }