2 namespace GuzzleHttp\Handler;
5 use Psr\Http\Message\RequestInterface;
8 * HTTP handler that uses cURL easy handles as a transport layer.
10 * When using the CurlHandler, custom curl options can be specified as an
11 * associative array of curl option constants mapping to values in the
12 * **curl** key of the "client" key of the request.
16 /** @var CurlFactoryInterface */
20 * Accepts an associative array of options:
22 * - factory: Optional curl factory used to create cURL handles.
24 * @param array $options Array of options to use with the handler
26 public function __construct(array $options = [])
28 $this->factory = isset($options['handle_factory'])
29 ? $options['handle_factory']
33 public function __invoke(RequestInterface $request, array $options)
35 if (isset($options['delay'])) {
36 usleep($options['delay'] * 1000);
39 $easy = $this->factory->create($request, $options);
40 curl_exec($easy->handle);
41 $easy->errno = curl_errno($easy->handle);
43 return CurlFactory::finish($this, $easy, $this->factory);