Lines Matching defs:response

264             $response =  Core::proxy(
266 function ($response) use ($connection, $transport, $request, $options) {
268 $this->lastRequest['response'] = $response;
270 if (isset($response['error']) === true) {
271 if ($response['error'] instanceof ConnectException || $response['error'] instanceof RingException) {
274 $exception = $this->getCurlRetryException($request, $response);
276 $this->logRequestFail($request, $response, $exception);
311 $exception = new TransportException($response['error']->getMessage());
312 $this->logRequestFail($request, $response, $exception);
318 if (isset($response['headers']['Warning'])) {
319 $this->logWarning($request, $response);
321 if (isset($response['body']) === true) {
322 $response['body'] = stream_get_contents($response['body']);
323 $this->lastRequest['response']['body'] = $response['body'];
326 if ($response['status'] >= 400 && $response['status'] < 500) {
329 $body = $response['body'] ?? '';
333 $this->process4xxError($request, $response, $ignore);
334 } elseif ($response['status'] >= 500) {
336 $this->process5xxError($request, $response, $ignore);
340 $response['body'] = $this->serializer->deserialize($response['body'], $response['transfer_stats']);
342 $this->logRequestSuccess($request, $response);
344 return isset($request['client']['verbose']) && $request['client']['verbose'] === true ? $response : $response['body'];
348 return $response;
383 public function logWarning(array $request, array $response): void
385 $this->log->warning('Deprecation', $response['headers']['Warning']);
392 * @param array $response
395 public function logRequestSuccess(array $request, array $response): void
397 $port = $request['client']['curl'][CURLOPT_PORT] ?? $response['transfer_stats']['primary_port'] ?? '';
398 $uri = $this->addPortInUrl($response['effective_url'], (int) $port);
408 'HTTP code' => $response['status'],
409 'duration' => $response['transfer_stats']['total_time'],
412 $this->log->debug('Response', array($response['body']));
420 'response' => $response['body'],
424 'HTTP code' => $response['status'],
425 'duration' => $response['transfer_stats']['total_time'],
434 * @param array $response
439 public function logRequestFail(array $request, array $response, \Exception $exception): void
441 $port = $request['client']['curl'][CURLOPT_PORT] ?? $response['transfer_stats']['primary_port'] ?? '';
442 $uri = $this->addPortInUrl($response['effective_url'], (int) $port);
452 'HTTP code' => $response['status'],
453 'duration' => $response['transfer_stats']['total_time'],
457 $this->log->warning('Response', array($response['body']));
465 'response' => $response,
469 'HTTP code' => $response['status'],
470 'duration' => $response['transfer_stats']['total_time'],
485 $response = $this->performRequest('HEAD', '/', null, null, $options);
486 $response = $response->wait();
493 if ($response['status'] === 200) {
571 protected function getCurlRetryException(array $request, array $response): ElasticsearchException
574 $message = $response['error']->getMessage();
576 switch ($response['curl']['errno']) {
666 private function process4xxError(array $request, array $response, array $ignore): ?ElasticsearchException
668 $statusCode = $response['status'];
673 $exception = $this->tryDeserialize400Error($response);
675 if (array_search($response['status'], $ignore) !== false) {
679 $responseBody = $this->convertBodyToString($response['body'], $statusCode, $exception);
696 $this->logRequestFail($request, $response, $exception);
701 private function process5xxError(array $request, array $response, array $ignore): ?ElasticsearchException
703 $statusCode = (int) $response['status'];
704 $responseBody = $response['body'];
709 $exception = $this->tryDeserialize500Error($response);
732 $this->logRequestFail($request, $response, $exception);
753 private function tryDeserialize400Error(array $response): ElasticsearchException
755 return $this->tryDeserializeError($response, BadRequest400Exception::class);
758 private function tryDeserialize500Error(array $response): ElasticsearchException
760 return $this->tryDeserializeError($response, ServerErrorResponseException::class);
763 private function tryDeserializeError(array $response, string $errorClass): ElasticsearchException
765 $error = $this->serializer->deserialize($response['body'], $response['transfer_stats']);
769 // $error is an array but we don't know the format, reuse the response body instead
771 return new $errorClass(json_encode($response['body']), (int) $response['status']);
786 $original = new $errorClass(json_encode($response['body']), $response['status']);
788 return new $errorClass("$type: $cause", (int) $response['status'], $original);
792 $original = new $errorClass(json_encode($response['body']), $response['status']);
798 return new $errorClass($errorEncoded, (int) $response['status'], $original);
802 $responseBody = $response['body'];