Check that ETag header exists

@param ResponseInterface $response
@return void
546805
private function checkEtag(ResponseInterface $response)
    {
        $eTag = $response->getHeaderLine('ETag');
        $fullURL = Controller::join_links(Director::absoluteBaseURL(), $this->url);

        if ($eTag) {
            $this->result->addMessage(
                "$fullURL includes an Etag header in response",
                ValidationResult::TYPE_GOOD
            );
            return;
        }
        $this->result->addError(
            "$fullURL is missing an Etag header",
            ValidationResult::TYPE_WARNING
        );
    }
98848
public function addEtag(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
    {
        if ($this->canEtag($request, $response)) {
            $streamData = $response->getBody()->getContents();
            $etag = 'W/"' . md5($streamData) . '"';
            $response = $response->withHeader('Etag', $etag);
            $response = $this->setNotModifyHeader($request, $response, $etag);
        }

        return $response;
    }
1130058
protected function handleErrors(ResponseInterface $response)
    {
        $body = $response->getBody()->__toString();
        switch ($response->getStatusCode()) {
            case 400:
                throw new DomainExceptions\BadRequestException($body);
                break;

            case 403:
                throw new DomainExceptions\ForbiddenException();
                break;

            case 404:
                throw new DomainExceptions\NotFoundException();
                break;

            case 500:
                throw new DomainExceptions\ServerErrorException();
                break;

            default:
                throw new DomainExceptions\UnknownErrorException();
                break;
        }
    }
78668
protected function fixResponse(ResponseInterface $response)
    {
        if ($response->getRequest()->getQuery()->getOption('batch')) {
            return false;
        }

        $rows = $response->getData();
        $empty = $rows === [];
        $this->setResponseData($response, $empty ? null : reset($rows));

        return $empty;
    }
923110
protected function addPolicyHeader(ResponseInterface $response)
    {
        $this->loadDefaultProfiles();

        $currentHeader = $response->getHeader($this->header);

        $initialConfig = [];
        if (count($currentHeader)) {
            $initialConfig = $this->decodeConfiguration($currentHeader[0]);
        }

        $initialDirectives = $this->encodeConfiguration($initialConfig);

        $this->mergeProfileWithConfig($initialConfig);

        $newDirectives = $this->encodeConfiguration($this->config);

        if ($newDirectives != $initialDirectives) {
            $response = $response->withHeader($this->header, $newDirectives);
        }

        return $response;
    }
799176
private static function withCorsHeaders(ResponseInterface $response, array $headers): ResponseInterface
	{
		foreach ($headers as $name => $value) {
			$response = $response->withHeader($name, $value);
		}

		return $response;
	}
914224
protected function emitHeaders(ResponseInterface $response){
        foreach($response->getHeaders() as $name => $values){
            if(strtolower($name) === "set-cookie"){
                foreach($values as $value){
                    header(sprintf("Set-Cookie: %s", $value), false);
                }
            }else{
                header(sprintf("%s: %s", $name, implode(", ", $values)));
            }
        }
    }
1266505
protected function addResponseHeaders(RequestInterface $request, Response $response)
    {
        $params = $request->getParams();
        $response->setHeader('Via', sprintf('%s GuzzleCache/%s', $request->getProtocolVersion(), Version::VERSION));

        $lookup = ($params['cache.lookup'] === true ? 'HIT' : 'MISS') . ' from GuzzleCache';
        if ($header = $response->getHeader('X-Cache-Lookup')) {
            // Don't add duplicates
            $values = $header->toArray();
            $values[] = $lookup;
            $response->setHeader('X-Cache-Lookup', array_unique($values));
        } else {
            $response->setHeader('X-Cache-Lookup', $lookup);
        }

        if ($params['cache.hit'] === true) {
            $xcache = 'HIT from GuzzleCache';
        } elseif ($params['cache.hit'] == 'error') {
            $xcache = 'HIT_ERROR from GuzzleCache';
        } else {
            $xcache = 'MISS from GuzzleCache';
        }

        if ($header = $response->getHeader('X-Cache')) {
            // Don't add duplicates
            $values = $header->toArray();
            $values[] = $xcache;
            $response->setHeader('X-Cache', array_unique($values));
        } else {
            $response->setHeader('X-Cache', $xcache);
        }

        if ($response->isFresh() === false) {
            $response->addHeader('Warning', sprintf('110 GuzzleCache/%s "Response is stale"', Version::VERSION));
            if ($params['cache.hit'] === 'error') {
                $response->addHeader('Warning', sprintf('111 GuzzleCache/%s "Revalidation failed"', Version::VERSION));
            }
        }
    }
669314
public function processResponse(Response $response) {
		if ($this->logCode) {
			$response->headers->set('C-Code-For-Logger', $this->logCode);
		}
	}
1152606
private function checkErrorResponse(ResponseInterface $response)
    {
        if ($response->getStatusCode() >= 500) {
            $errors = json_decode($response->getBody()->__toString(), true)['details'];

            throw new \RuntimeException(
                'An error occurred creating the expectation: '
                . ($errors ? var_export($errors, true) : '')
                . $response->getBody()->__toString());
        }

        if ($response->getStatusCode() >= 400) {
            throw new \RuntimeException('Request error while creating the expectation');
        }
    }
120663
public function sendResponseHttpHeaders(ResponseInterface $response):void
    {
        // checking
        if (headers_sent()) {
            throw new ResponseSenderException("A response has already been sent to the web browser",
                $this);
        }

        // removing PHP native HTTP headers (if enabled)
        if ($this->removePhpHttpHeaders) {
            foreach (headers_list() as $header) {
                header_remove(explode(":", $header)[0]);
            }
        }

        // sending response HTTP headers
        $this->sendHttpVersionHeader(
            $response->getProtocolVersion(),
            $response->getStatusCode(),
            $response->getReasonPhrase()
        );
        $this->sendHttpHeaders($this->listResponseHeaders($response));
    }
175462
public function respond(ResponseInterface $response)
    {
        if (headers_sent()) {
            throw new HeadersAlreadySentException('Headers were already sent');
        }

        /** @var PsrResponseInterface $r */
        $r = $response;

        $status = sprintf('HTTP/%s %s %s', $r->getProtocolVersion(), $r->getStatusCode(), $r->getReasonPhrase());
        header($status, TRUE);

        foreach ($r->getHeaders() as $name => $values) {
            $header = sprintf('%s: %s', $name, $r->getHeaderLine($name));
            header($header, FALSE);
        }

        echo $r->getBody();
    }
1299768
protected function checkResponse(ResponseInterface $response, $data)
    {
        $exception = null;

        if (isset($data['errors'])) {
            foreach ($data['errors'] as $error) {
                $exception = new YextException($error['message'], $error['errorCode'], $exception);
            }
        }

        if ($exception != null) {
            throw $exception;
        }
    }
479369
protected function isRedirect(ResponseInterface $response)
    {
        $statusCode = $response->getStatusCode();

        return $statusCode > 300 && $statusCode < 400 && $response->hasHeader('Location');
    }
717661
private function processResponse(ResponseInterface $response)
    {
        if (200 !== $response->getStatusCode()) {
            throw new \RuntimeException('Query to the API server did not result in an appropriate response code');
        }

        $body = guzzle_json_decode((string) $response->getBody(), true);

        if ('OK' !== $body['error']) {
            throw new \RuntimeException('Query to the API server did not result in an appropriate response code');
        }

        return $body;
    }
527849
protected function withEncryptedCookies(ResponseInterface $response): ResponseInterface
    {
        //$cookiesManager = new CookiesManager();
        //$cookies = CookiesManager::parseHeaders($response->getHeader('Set-Cookie'));

        $cookies = CookiesManager::parseSetCookieHeader($response->getHeader('Set-Cookie'));

        // remove all the cookies
        $response = $response->withoutHeader('Set-Cookie');

        //$header = [];
        foreach ($cookies as $name => $cookie) {
            if (! in_array($name, $this->bypassed)) {
                $cookie['value'] = $this->encrypt($cookie['value']);
            }

            //$cookiesManager->set($name, $value);
            // add again all the cookies (and some are now encrypted)
            $response = $response->withAddedHeader('Set-Cookie', CookiesManager::toHeader($name, $cookie));
        }

        return $response;
    }
950246
protected function checkResponse(ResponseInterface $response, $data)
    {
        if (isset($data['error'])) {
            throw new IdentityProviderException((string) $data['error'], (int) $data['status'], $data);
        }
    }