@param string $file
@param ResponseInterface $response

@return ResponseInterface
965078
public function loadIgnoreResponse(string $file, ResponseInterface $response) : ResponseInterface
    {
        return $this->includeResponse('loadIgnore', $file, $response);
    }
320764
public function forFile(FileInterface $file)
    {
        $filter = function ($review) use ($file) {
            if ($review->canReview($file)) {
                return true;
            }

            return false;
        };

        return $this->select($filter);
    }
1102182
public static function buildFromPsrResponse(ResponseInterface $response)
    {
        return new static(
            $response->getStatusCode(),
            $response->getHeaders(),
            $response->getBody(),
            $response->getProtocolVersion(),
            $response->getReasonPhrase()
        );
    }
163340
private function handleRedirect(ResponseInterface $response): ResponseInterface
    {
        if ($this->debugbar->isDataPersisted() || session_status() === PHP_SESSION_ACTIVE) {
            $this->debugbar->stackData();
        }

        return $response;
    }
531458
public function response(ResponseInterface $response)
    {
        $this->lastResponse = $response;

        $content = $response->getBody()->getContents();

        $decoded = json_decode($content); // parse as object
        $data = $decoded;

        if (!empty($decoded)) {
            reset($decoded);
            $data = current($decoded); // get first attribute from array, e.g.: subscription, subscriptions, errors.
        }

        $this->checkRateLimit($response)
            ->checkForErrors($response, $data);

        return $data;
    }
380317
public static function setResponse(ResponseInterface $response)
    {
        $coroutineId = self::getCoroutineId();
        self::$context[$coroutineId][self::RESPONSE_KEY] = $response;
    }
383773
private function decorateResponse(ResponseInterface $response)
    {
        if ($response instanceof Http\Response) {
            return $response;
        }

        return new Http\Response($this, $response);
    }
1201851
protected function deserializeResponse(ResponseInterface $response)
    {
        // First, we need an encoder that filters out null values.
        $encoders = [new JsonEncoder()];

        // Attempt normalizing each key in this order, including denormalizing recursively.
        $extractor = new NotificationTypeExtractor();
        $extractor->setClass($this->service->getClass());
        $normalizers = [
            new UnixMillisecondNormalizer(),
            new UriNormalizer(),
            new ObjectNormalizer(null, null, null, $extractor),
            new ArrayDenormalizer(),
        ];

        $serializer = new Serializer($normalizers, $encoders);
        // @todo Handle exception returns.
        return $serializer->deserialize($response->getBody(), Notification::class.'[]', 'json');
    }
1341374
public function prepareCache(ResponseInterface $response)
    {
        /** @var MessageInterface|ResponseInterface $response */

        // Force cachable
        if ($this->getCachable() === static::CACHE_ENABLE) {
            // Expires.
            $response = $response->withoutHeader('Expires')->withHeader(
                'Expires',
                gmdate('D, d M Y H:i:s', time() + 900) . ' GMT'
            );

            // Last modified.
            if ($this->modifiedDate instanceof \DateTime) {
                $this->modifiedDate->setTimezone(new \DateTimeZone('UTC'));

                $response = $response->withoutHeader('Last-Modified')->withHeader(
                    'Last-Modified',
                    $this->modifiedDate->format('D, d M Y H:i:s') . ' GMT'
                );
            }
        } elseif ($this->getCachable() === static::CACHE_DISABLE) {
            // Force uncachable

            // Expires in the past.
            $response = $response->withoutHeader('Expires')->withHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT');

            // Always modified.
            $response = $response->withoutHeader('Last-Modified')->withHeader(
                'Last-Modified',
                gmdate('D, d M Y H:i:s') . ' GMT'
            );
            $response = $response->withoutHeader('Cache-Control')->withHeader(
                'Cache-Control',
                'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
            );

            // HTTP 1.0
            $response = $response->withHeader('pragma', 'no-cache');
        }

        return $response;
    }
879326
protected function configureResponse(ResponseInterface $Response){
        $Response->setRequest($this->Request);
        $Response->extract();
        return $Response;
    }
34892
private static function range(ResponseInterface $response, string $range): ResponseInterface
    {
        $response = $response->withHeader('Accept-Ranges', 'bytes');

        if (empty($range) || !($range = self::parseRangeHeader($range))) {
            return $response;
        }

        list($first, $last) = $range;
        $size = $response->getBody()->getSize();

        if ($last === null) {
            $last = $size - 1;
        }

        return $response
            ->withStatus(206)
            ->withHeader('Content-Length', (string) ($last - $first + 1))
            ->withHeader('Content-Range', sprintf('bytes %d-%d/%d', $first, $last, $size));
    }
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;
    }
1292003
protected function mutateHeaders(ResponseInterface $response, File $file)
    {
        $response = $response->withHeader('Content-Type', 'application/force-download');
        $response = $response->withAddedHeader('Content-Type', 'application/octet-stream');
        $response = $response->withAddedHeader('Content-Type', 'application/download');

        $response = $response->withHeader('Content-Transfer-Encoding', 'binary');

        $response = $response->withHeader(
            'Content-Disposition',
            sprintf('attachment; filename="%s"', $file->base_name)
        );

        return $response;
    }
1224513
private function sendHeaders(ResponseInterface $response)
    {
        // Set proper protocol, status code (and reason phrase) header
        if ($response->getReasonPhrase()) {
            header(sprintf(
                'HTTP/%s %d %s',
                $response->getProtocolVersion(),
                $response->getStatusCode(),
                $response->getReasonPhrase()
            ));
        } else {
            header(sprintf(
                'HTTP/%s %d',
                $response->getProtocolVersion(),
                $response->getStatusCode()
            ));
        }

        // Loop through all headers
        foreach ($response->getHeaders() as $name => $values) {
            // Sanitize header name
            $name  = $this->sanitizeHeaderName($name);
            // First iteration, if more than one header with the same name
            // exists the $first parameter to the header method will indicate
            // if a second (etc) header should replace the previous one or
            // if multiple headers with the same name should be sent
            $first = true;
            foreach ($values as $value) {
                // Send header
                header(sprintf('%s: %s', $name, $value), $first);
                $first = false;
            }
        }
    }
799176
private static function withCorsHeaders(ResponseInterface $response, array $headers): ResponseInterface
	{
		foreach ($headers as $name => $value) {
			$response = $response->withHeader($name, $value);
		}

		return $response;
	}
679547
public function downloadFile(FileInterface $file)
    {
        /**
         * @var string $content
         */
        $content = $this
            ->filesystem
            ->read($this
                ->fileIdentifierTransformer
                ->transform($file)
            );

        $file->setContent($content);

        return $file;
    }
631164
private function decodeResponse( ResponseInterface $response ) {
		$resultArray = json_decode( $response->getBody(), true );

		$this->logWarnings( $resultArray );
		$this->throwUsageExceptions( $resultArray );

		return $resultArray;
	}