Open Monograph Press  3.3.0
CurlHandler.php
1 <?php
2 namespace GuzzleHttp\Handler;
3 
6 
15 {
17  private $factory;
18 
26  public function __construct(array $options = [])
27  {
28  $this->factory = isset($options['handle_factory'])
29  ? $options['handle_factory']
30  : new CurlFactory(3);
31  }
32 
33  public function __invoke(RequestInterface $request, array $options)
34  {
35  if (isset($options['delay'])) {
36  usleep($options['delay'] * 1000);
37  }
38 
39  $easy = $this->factory->create($request, $options);
40  curl_exec($easy->handle);
41  $easy->errno = curl_errno($easy->handle);
42 
43  return CurlFactory::finish($this, $easy, $this->factory);
44  }
45 }
GuzzleHttp\Handler\CurlFactory\finish
static finish(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory)
Definition: CurlFactory.php:101
GuzzleHttp\Handler\CurlHandler\__construct
__construct(array $options=[])
Definition: CurlHandler.php:29
Psr\Http\Message\RequestInterface
Definition: vendor/psr/http-message/src/RequestInterface.php:24
GuzzleHttp\Handler
Definition: CurlFactory.php:2
GuzzleHttp\Handler\CurlFactory
Definition: CurlFactory.php:15
GuzzleHttp\Psr7
Definition: AppendStream.php:2
GuzzleHttp\Handler\CurlHandler
Definition: CurlHandler.php:14
GuzzleHttp\Handler\CurlHandler\__invoke
__invoke(RequestInterface $request, array $options)
Definition: CurlHandler.php:36