@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public function __construct($maxConcurrent = 10, $usleep = 100000, $userAgent = 'cvweiss/guzzler/', $curlOptions = []) |
17 | 17 | { |
18 | - $curlOptions = $curlOptions == [] ? [CURLOPT_FRESH_CONNECT => false] : $curlOptions; |
|
18 | + $curlOptions = $curlOptions == [] ? [CURLOPT_FRESH_CONNECT => false] : $curlOptions; |
|
19 | 19 | |
20 | 20 | $this->curl = new \GuzzleHttp\Handler\CurlMultiHandler(); |
21 | 21 | $this->handler = \GuzzleHttp\HandlerStack::create($this->curl); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $ms = microtime(); |
35 | 35 | do { |
36 | 36 | $this->curl->tick(); |
37 | - if ($this->concurrent >= $this->maxConcurrent) usleep(max(1, min(1000000, $this->usleep))); |
|
37 | + if ($this->concurrent >= $this->maxConcurrent) usleep(max(1, min(1000000, $this->usleep))); |
|
38 | 38 | } while ($this->concurrent >= $this->maxConcurrent); |
39 | 39 | return max(0, microtime() - $ms); |
40 | 40 | } |
@@ -61,16 +61,16 @@ discard block |
||
61 | 61 | $this->verifyCallable($fulfilled); |
62 | 62 | $this->verifyCallable($rejected); |
63 | 63 | |
64 | - while ($this->concurrent >= $this->maxConcurrent) $this->tick(); |
|
64 | + while ($this->concurrent >= $this->maxConcurrent) $this->tick(); |
|
65 | 65 | |
66 | - $params['uri'] = $uri; |
|
67 | - $params['fulfilled'] = $fulfilled; |
|
68 | - $params['rejected'] = $rejected; |
|
69 | - $params['setup'] = $setup; |
|
70 | - $params['callType'] = $callType; |
|
71 | - $params['body'] = $body; |
|
66 | + $params['uri'] = $uri; |
|
67 | + $params['fulfilled'] = $fulfilled; |
|
68 | + $params['rejected'] = $rejected; |
|
69 | + $params['setup'] = $setup; |
|
70 | + $params['callType'] = $callType; |
|
71 | + $params['body'] = $body; |
|
72 | 72 | |
73 | - $redis = $this->applyEtag($setup, $params); |
|
73 | + $redis = $this->applyEtag($setup, $params); |
|
74 | 74 | |
75 | 75 | $guzzler = $this; |
76 | 76 | $request = new \GuzzleHttp\Psr7\Request($callType, $uri, $setup, $body); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $guzzler->dec(); |
80 | 80 | $content = (string) $response->getBody(); |
81 | 81 | $this->lastHeaders = array_change_key_case($response->getHeaders()); |
82 | - $this->applyEtagPost($this->lastHeaders, $params['uri'], $redis); |
|
82 | + $this->applyEtagPost($this->lastHeaders, $params['uri'], $redis); |
|
83 | 83 | $fulfilled($guzzler, $params, $content); |
84 | 84 | }, |
85 | 85 | function($connectionException) use (&$guzzler, &$rejected, &$params) { |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | if ($etag != "") $setup['If-None-Match'] = $etag; |
101 | 101 | } |
102 | 102 | unset($setup['etag']); |
103 | - return $redis; |
|
103 | + return $redis; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | protected function applyEtagPost($headers, $uri, $redis) |
107 | 107 | { |
108 | 108 | if (isset($headers['etag']) && $redis !== null) { |
109 | - $redis->setex("guzzler:etags:$uri", $this->etagTTL, $headers['etag'][0]); |
|
110 | - } |
|
109 | + $redis->setex("guzzler:etags:$uri", $this->etagTTL, $headers['etag'][0]); |
|
110 | + } |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | public function verifyCallable($callable) |
@@ -124,6 +124,6 @@ discard block |
||
124 | 124 | |
125 | 125 | public function setEtagTTL($ttl) |
126 | 126 | { |
127 | - $this->etagTTL = $ttl; |
|
127 | + $this->etagTTL = $ttl; |
|
128 | 128 | } |
129 | 129 | } |