Lines Matching refs:easy
41 $easy = new EasyHandle;
42 $easy->request = $request;
43 $easy->options = $options;
44 $conf = $this->getDefaultConf($easy);
45 $this->applyMethod($easy, $conf);
46 $this->applyHandlerOptions($easy, $conf);
47 $this->applyHeaders($easy, $conf);
55 $conf[CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy);
56 $easy->handle = $this->handles
59 curl_setopt_array($easy->handle, $conf);
61 return $easy;
64 public function release(EasyHandle $easy) argument
66 $resource = $easy->handle;
67 unset($easy->handle);
90 * @param EasyHandle $easy
97 EasyHandle $easy, argument
100 if (isset($easy->options['on_stats'])) {
101 self::invokeStats($easy);
104 if (!$easy->response || $easy->errno) {
105 return self::finishError($handler, $easy, $factory);
109 $factory->release($easy);
112 $body = $easy->response->getBody();
117 return new FulfilledPromise($easy->response);
120 private static function invokeStats(EasyHandle $easy) argument
122 $curlStats = curl_getinfo($easy->handle);
123 $curlStats['appconnect_time'] = curl_getinfo($easy->handle, CURLINFO_APPCONNECT_TIME);
125 $easy->request,
126 $easy->response,
128 $easy->errno,
131 call_user_func($easy->options['on_stats'], $stats);
136 EasyHandle $easy, argument
141 'errno' => $easy->errno,
142 'error' => curl_error($easy->handle),
143 'appconnect_time' => curl_getinfo($easy->handle, CURLINFO_APPCONNECT_TIME),
144 ] + curl_getinfo($easy->handle);
146 $factory->release($easy);
149 if (empty($easy->options['_err_message'])
150 && (!$easy->errno || $easy->errno == 65)
152 return self::retryFailedRewind($handler, $easy, $ctx);
155 return self::createRejection($easy, $ctx);
158 private static function createRejection(EasyHandle $easy, array $ctx) argument
170 if ($easy->onHeadersException) {
174 $easy->request,
175 $easy->response,
176 $easy->onHeadersException,
194 $easy->request->getUri()
199 $error = isset($connectionErrors[$easy->errno])
200 ? new ConnectException($message, $easy->request, null, $ctx)
201 : new RequestException($message, $easy->request, $easy->response, null, $ctx);
206 private function getDefaultConf(EasyHandle $easy) argument
209 '_headers' => $easy->request->getHeaders(),
210 CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(),
211 CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''),
221 $version = $easy->request->getProtocolVersion();
233 private function applyMethod(EasyHandle $easy, array &$conf) argument
235 $body = $easy->request->getBody();
239 $this->applyBody($easy->request, $easy->options, $conf);
243 $method = $easy->request->getMethod();
246 if (!$easy->request->hasHeader('Content-Length')) {
301 private function applyHeaders(EasyHandle $easy, array &$conf) argument
317 if (!$easy->request->hasHeader('Accept')) {
338 private function applyHandlerOptions(EasyHandle $easy, array &$conf) argument
340 $options = $easy->options;
369 $accept = $easy->request->getHeaderLine('Accept-Encoding');
393 $easy->sink = $sink;
400 $easy->sink = Psr7\stream_for($conf[CURLOPT_FILE]);
430 $scheme = $easy->request->getUri()->getScheme();
432 $host = $easy->request->getUri()->getHost();
510 EasyHandle $easy, argument
515 $body = $easy->request->getBody();
524 return self::createRejection($easy, $ctx);
528 if (!isset($easy->options['_curl_retries'])) {
529 $easy->options['_curl_retries'] = 1;
530 } elseif ($easy->options['_curl_retries'] == 2) {
537 return self::createRejection($easy, $ctx);
539 $easy->options['_curl_retries']++;
542 return $handler($easy->request, $easy->options);
545 private function createHeaderFn(EasyHandle $easy) argument
547 if (isset($easy->options['on_headers'])) {
548 $onHeaders = $easy->options['on_headers'];
559 $easy,
565 $easy->createResponse();
568 $onHeaders($easy->response);
572 $easy->onHeadersException = $e;
578 $easy->headers = [$value];
580 $easy->headers[] = $value;