@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | public function __construct($maxConcurrent = 10, $usleep = 100000, $userAgent = 'cvweiss/guzzler/', $curlOptions = []) |
16 | 16 | { |
17 | - $curlOptions = $curlOptions == [] ? [CURLOPT_SSL_VERIFYHOST => false, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_FRESH_CONNECT => false] : $curlOptions; |
|
17 | + $curlOptions = $curlOptions == [] ? [CURLOPT_SSL_VERIFYHOST => false, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_FRESH_CONNECT => false] : $curlOptions; |
|
18 | 18 | |
19 | 19 | $this->curl = new \GuzzleHttp\Handler\CurlMultiHandler(); |
20 | 20 | $this->handler = \GuzzleHttp\HandlerStack::create($this->curl); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $ms = microtime(); |
34 | 34 | do { |
35 | 35 | $this->curl->tick(); |
36 | - if ($this->concurrent >= $this->maxConcurrent) usleep(max(1, min(1000000, $this->usleep))); |
|
36 | + if ($this->concurrent >= $this->maxConcurrent) usleep(max(1, min(1000000, $this->usleep))); |
|
37 | 37 | } while ($this->concurrent >= $this->maxConcurrent); |
38 | 38 | return max(0, microtime() - $ms); |
39 | 39 | } |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | $this->verifyCallable($fulfilled); |
61 | 61 | $this->verifyCallable($rejected); |
62 | 62 | |
63 | - $params['uri'] = $uri; |
|
64 | - $params['fulfilled'] = $fulfilled; |
|
65 | - $params['rejected'] = $rejected; |
|
66 | - $params['setup'] = $setup; |
|
67 | - $params['callType'] = $callType; |
|
68 | - $params['body'] = $body; |
|
63 | + $params['uri'] = $uri; |
|
64 | + $params['fulfilled'] = $fulfilled; |
|
65 | + $params['rejected'] = $rejected; |
|
66 | + $params['setup'] = $setup; |
|
67 | + $params['callType'] = $callType; |
|
68 | + $params['body'] = $body; |
|
69 | 69 | |
70 | 70 | $redis = isset($setup['etag']) ? $setup['etag'] : null; |
71 | 71 | if ($redis !== null && $params['callType'] == 'GET') { |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | $ms = microtime(); |
34 | 34 | do { |
35 | 35 | $this->curl->tick(); |
36 | - if ($this->concurrent >= $this->maxConcurrent) usleep(max(1, min(1000000, $this->usleep))); |
|
36 | + if ($this->concurrent >= $this->maxConcurrent) { |
|
37 | + usleep(max(1, min(1000000, $this->usleep))); |
|
38 | + } |
|
37 | 39 | } while ($this->concurrent >= $this->maxConcurrent); |
38 | 40 | return max(0, microtime() - $ms); |
39 | 41 | } |
@@ -70,7 +72,9 @@ discard block |
||
70 | 72 | $redis = isset($setup['etag']) ? $setup['etag'] : null; |
71 | 73 | if ($redis !== null && $params['callType'] == 'GET') { |
72 | 74 | $etag = $redis->get("guzzler:etags:$uri"); |
73 | - if ($etag != "") $setup['If-None-Match'] = $etag; |
|
75 | + if ($etag != "") { |
|
76 | + $setup['If-None-Match'] = $etag; |
|
77 | + } |
|
74 | 78 | } |
75 | 79 | unset($setup['etag']); |
76 | 80 | |
@@ -81,7 +85,9 @@ discard block |
||
81 | 85 | $guzzler->dec(); |
82 | 86 | $content = (string) $response->getBody(); |
83 | 87 | $this->lastHeaders = array_change_key_case($response->getHeaders()); |
84 | - if (isset($this->lastHeaders['etag']) && strlen($content) > 0 && $redis !== null) $redis->setex("guzzler:etags:" . $params['uri'], 604800, $this->lastHeaders['etag'][0]); |
|
88 | + if (isset($this->lastHeaders['etag']) && strlen($content) > 0 && $redis !== null) { |
|
89 | + $redis->setex("guzzler:etags:" . $params['uri'], 604800, $this->lastHeaders['etag'][0]); |
|
90 | + } |
|
85 | 91 | |
86 | 92 | $fulfilled($guzzler, $params, $content); |
87 | 93 | }, |