コード例 #1
0
ファイル: CurlHandler.php プロジェクト: xbugster/guzzle
 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);
 }
コード例 #2
0
ファイル: CurlMultiHandler.php プロジェクト: Rayac/search
 public function __invoke(RequestInterface $request, array $options)
 {
     $easy = $this->factory->create($request, $options);
     $id = (int) $easy->handle;
     $promise = new Promise([$this, 'execute'], function () use($id) {
         return $this->cancel($id);
     });
     $this->addRequest(['easy' => $easy, 'deferred' => $promise]);
     return $promise;
 }
コード例 #3
0
 private static function finishError(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory)
 {
     // Get error information and release the handle to the factory.
     $ctx = ['errno' => $easy->errno, 'error' => curl_error($easy->handle) ?: curl_strerror($easy->errno)] + curl_getinfo($easy->handle);
     $factory->release($easy);
     // Retry when nothing is present or when curl failed to rewind.
     if (empty($easy->options['_err_message']) && (!$easy->errno || $easy->errno == 65)) {
         return self::retryFailedRewind($handler, $easy, $ctx);
     }
     return self::createRejection($easy, $ctx);
 }