Restores response properties from the given data.
@param Response $response the response to be restored.
@param array $data the response property data.
@since 2.0.3
176908
protected function restoreResponse($response, $data)
    {
        foreach (['format', 'protocolVersion', 'statusCode', 'reasonPhrase', 'content'] as $name) {
            $response->{$name} = $data[$name];
        }

        if (isset($data['headers'])) {
            $response->setHeaders($data['headers']);
        }

        if (isset($data['cookies']) && is_array($data['cookies'])) {
            $response->getCookies()->fromArray(array_merge($data['cookies'], $response->getCookies()->toArray()));
        }

        if (!empty($data['dynamicPlaceholders']) && is_array($data['dynamicPlaceholders'])) {
            $response->content = $this->updateDynamicContent($response->content, $data['dynamicPlaceholders'], true);
        }
        $this->afterRestoreResponse($data['cacheData'] ?? null);
    }
613462
private function restoreResponseBody(Request $request, Response $response)
    {
        if ($response->headers->has('X-Body-Eval')) {
            ob_start();

            if ($response->headers->has('X-Body-File')) {
                include $response->headers->get('X-Body-File');
            } else {
                eval('; ?>'.$response->getContent().'<?php ;');
            }

            $response->setContent(ob_get_clean());
            $response->headers->remove('X-Body-Eval');
            if (!$response->headers->has('Transfer-Encoding')) {
                $response->headers->set('Content-Length', \strlen($response->getContent()));
            }
        } elseif ($response->headers->has('X-Body-File')) {
            // Response does not include possibly dynamic content (ESI, SSI), so we need
            // not handle the content for HEAD requests
            if (!$request->isMethod('HEAD')) {
                $response->setContent(file_get_contents($response->headers->get('X-Body-File')));
            }
        } else {
            return;
        }

        $response->headers->remove('X-Body-File');
    }
1358918
private function _parseResponse(Response $response)
    {
        switch ($this->_format) {
            case self::FORMAT_JSON:
                return json_decode($response, $this->_isJsonDecodeAssoc);
                break;
            default:
                return $response;
        }
    }
991517
private function processResponse(Response $response)
    {
        $response = $response->getBody()->getContents();
        $response = json_decode($response, true);

        return $response;
    }
792638
protected static function handleResponse($response)
    {
        self::resolveContentType($response);

        $body = $response->getBody();
        $response = json_decode($body);

        self::resolveErrorResponse($response);

        return $response;
    }
1179292
protected function modifyResponse(array $response = array())
    {
        if (!empty($response['html']))
        {
            $replace = array('<![CDATA[' => '', ']]>' => '', '\'' => '"');
            $response['html'] = str_ireplace(array_keys($replace), array_values($replace), $response['html']);
        }

        return $response;
    }
756005
protected function logResponse(Response $response)
    {
        $raw_body = (string) $response->getBody();
        $body = json_decode($raw_body, true);
        if ($body === null) {
            // the response body is not in JSON format
            $this->logger->error($raw_body);
        } elseif (isset($body['error'])) {
            if (isset($body['message'])) {
                $this->logger->error($body['message']);
            }
        } else {
            if (isset($body['message'])) {
                $this->logger->info(sprintf('Accepted %s', $body['message']));
            }

            if (isset($body['url'])) {
                $this->logger->info(sprintf('You can see the build on %s', $body['url']));
            }
        }
    }
468853
protected function checkResponse(Response $response)
    {
        $status = $response->getStatusCode();
        $reason = $response->getReasonPhrase();
        switch ($status) {
            case '403':
                throw new Exceptions\GeocodioAuthError($reason);
                break;

            case '422':
                throw new Exceptions\GeocodioDataError($reason);
                break;

            case '500':
                throw new Exceptions\GeocodioServerError($reason);
                break;

            case '200':
                return $response;
                break;

            default:
                throw new Exceptions\GeocodioException("There was a problem with your request - $reason");
                break;
        }
    }
690521
private function insertResponseCollectionIntoData(Response $response, $collectionName, array &$data)
    {
        $property = 'cache' . ucfirst($collectionName);
        if ($this->{$property} === false) {
            return;
        }

        $collection = $response->{$collectionName};
        $all = is_array($collection) ? $collection : $collection->toArray();
        if (is_array($this->{$property})) {
            $filtered = [];
            foreach ($this->{$property} as $name) {
                if ($collectionName === 'headers') {
                    $name = strtolower($name);
                }
                if (isset($all[$name])) {
                    $filtered[$name] = $all[$name];
                }
            }
            $all = $filtered;
        }
        $data[$collectionName] = $all;
    }
284773
public static function populateResponseData(IResponse $response, &$dataObject): void
    {
        foreach (array_keys($response->data()) as $key) {
            $method = 'set';
            $method .= ucfirst(Str::camel($key));
            if (!method_exists($dataObject, $method)) {
                continue;
            }

            $dataObject->{$method}($response->{$key});
        }
    }
172
public function addResponse($key, array $response)
    {
        $originalRequest = isset($this->request[$key]) ? $this->request[$key] : null;
        $responseBody = isset($response['body']) ? $response['body'] : null;
        $responseError = isset($response['error']) ? $response['error'] : null;
        $responseMethod = isset($response['method']) ? $response['method'] : null;

        $this->responses[$key] = new Response($originalRequest, $responseBody, $responseError, $responseMethod);
    }
279450
public function respondWithData(array $data)
    {

        $responseData = $this->getResponseStructure(true, $data, '');
        $response = new JsonResponse($responseData, $this->getStatusCode(), $this->getHeaders());
        return $response;
    }
300937
public function prepareForResponse(Response $response) {
		$response->setStatus($this->httpStatus);
		$response->setHeader('Content-Type: text/html; charset=' . N2N::CHARSET);
		$response->setHeader('Location: ' . $this->httpLocation);
	}
983726
private function parseResponse($response) {
        $response = trim($response);
        $this->responseStatus = (int) substr($response, 0, 3);
        $this->response = substr($response, 4);
    }
933681
protected function respond($success, $response)
    {
        if (Arr::get($response, 'object') !== 'list') {
            $success = (!array_key_exists('error', $response));

            return $this->mapResponse($success, $response);
        }

        $responses = [];

        foreach ($response['data'] as $responds) {
            $success = (!array_key_exists('error', $responds));

            $responses[] = $this->mapResponse($success, $responds);
        }

        return $responses;
    }
808354
public function packetResponse(array $response = null)
    {

        // Act as setter
        if (!empty($response)) {
            $this->packets_response = $response;
        }

        return $this->packets_response;
    }
439684
public function setResponse($response)
    {
        $xml = simplexml_load_string($response);
        if (!empty($xml->error)) {
            $this->message = (string) $xml->error;
        }
    }