PluginProbe
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more / 2.5.7
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more v2.5.7
3.7.2 3.7.1 3.7.0 3.6.0 3.6.1 3.5.2 trunk 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.6.0 2.6.1 All 73 releases
stockpack / vendor / guzzlehttp / guzzle / src / Handler / CurlHandler.php

CurlHandler.php in StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more 2.5.7, at vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php

46 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace GuzzleHttp\Handler;
3
4 use GuzzleHttp\Psr7;
5 use Psr\Http\Message\RequestInterface;
6
7 /**
8 * HTTP handler that uses cURL easy handles as a transport layer.
9 *
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.
13 */
14 class CurlHandler
15 {
16 /** @var CurlFactoryInterface */
17 private $factory;
18
19 /**
20 * Accepts an associative array of options:
21 *
22 * - factory: Optional curl factory used to create cURL handles.
23 *
24 * @param array $options Array of options to use with the handler
25 */
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 }
46