@param ResponseInterface $response

@return ResponseInterface
5300
public function modify(ResponseInterface $response) : ResponseInterface
    {
        /** @var ResponseModifierInterface $modifier */
        foreach ($this->collection as $modifier) {
            $response = $modifier->modify($response);
        }

        return $response;
    }
751721
public function execute(ResponseInterface $response): ResponseInterface
    {
        if ($response->getStatusCode() !== self::STATUS_CODE_OK) {
            throw ExceptionFactory::createExceptionForResponse(
                $this->fetchErrorMessages($response),
                $response->getStatusCode(),
                $this->getResponseId($response)
            );
        }

        return $response;
    }
1021278
protected function setPsrResponse( \Psr\Http\Message\ResponseInterface $response )
	{
		$this->response->setStatus( $response->getStatusCode() );

		foreach( $response->getHeaders() as $key => $value ) {
			foreach( (array) $value as $val ) {
				$this->response->setHeader( $key, $val );
			}
		}

		return (string) $response->getBody();
	}
314048
protected function generateResponse(ResponseInterface $response): ?JourneyResponse
    {
        $json = $this->validateJson($response);
        if (isset($json['JourneyDetail'])) {
            return JourneyResponse::createFromArray($json['JourneyDetail']);
        }

        return null;
    }
1014376
public static function getContent(ResponseInterface $response)
    {
        $body = $response->getBody()->__toString();
        if (strpos($response->getHeaderLine('Content-Type'), 'application/json') === 0) {
            $content = json_decode($body, true);
            if (JSON_ERROR_NONE === json_last_error()) {
                return $content;
            }
        }

        return $body;
    }
978334
public function respond( ResponseInterface $response ) {
		if ( ! headers_sent() ) {
			$this->sendHeaders( $response );
		}
		$this->sendBody( $response );
	}
881059
protected function getBody( ResponseInterface $response ) {
		$body = $response->getBody();
		if ( $body->isSeekable() ) {
			$body->rewind();
		}
		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;
    }
599820
protected function finalize(ResponseInterface $response)
    {
        // stop PHP sending a Content-Type automatically
        ini_set('default_mimetype', '');

        $request = $this->container->get('request');
        if ($this->isEmptyResponse($response) && !$this->isHeadRequest($request)) {
            return $response->withoutHeader('Content-Type')->withoutHeader('Content-Length');
        }

        // Add Content-Length header if `addContentLengthHeader` setting is set
        if (isset($this->container->get('settings')['addContentLengthHeader']) &&
            $this->container->get('settings')['addContentLengthHeader'] == true) {
            if (ob_get_length() > 0) {
                throw new RuntimeException("Unexpected data in output buffer. " .
                    "Maybe you have characters before an opening <?php tag?");
            }
            $size = $response->getBody()->getSize();
            if ($size !== null && !$response->hasHeader('Content-Length')) {
                $response = $response->withHeader('Content-Length', (string) $size);
            }
        }

        // clear the body if this is a HEAD request
        if ($this->isHeadRequest($request)) {
            return $response->withBody(new Body(fopen('php://temp', 'r+')));
        }

        return $response;
    }
170865
private function parseExam(ResponseInterface $response)
    {
        $body = $this->checkAndThrow($response);

        // form => 考试形式, district => 校区
        return Parser::table($body, '#DataGrid1', [
            'code', 'name', 'student_name', 'time', 'location', 'form', 'seat', 'district'
        ], 8);
    }
760389
protected function parseResponse(ResponseInterface $response)
    {
        $content = (string) $response->getBody();

        if(strpos($content, "callback") !== false){
            $lpos = strpos($content, "(");
            $rpos = strrpos($content, ")");
            $content  = substr($content, $lpos + 1, $rpos - $lpos -1);

            return $this->parseJson($content);
        } else if(strpos($content, "access_token=") !== false) {
            $result = array();
            parse_str($content, $result);
            return $result;
        } else {
            return parent::parseResponse($response);
        }
    }
583612
private function decodeResponse(ResponseInterface $response)
    {
        $string = (string) $response->getBody();
        $data = json_decode($string, true);

        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new JsonDecodeException($string);
        }

        return $data;
    }
1184627
protected function sendHeaders(ResponseInterface $response): JsonRenderer
    {
        foreach ($response->getHeaders() as $header => $value) {
            if (is_array($value) === true) {
                $value = implode(', ', $value);
            }

            header(sprintf(
                '%s: %s',
                $header,
                $value
            ));
        }

        return $this;
    }
403753
protected function convertResponse(ResponseInterface $response)
    {
        $this->response->setContent($response->getBody());
        $this->response->setStatusCode($response->getStatusCode());
        foreach ($response->getHeaders() as $name => $values) {
            $this->response->setHeader($name, implode(', ', $values));
        }

        return $this->response;
    }
1120780
private function injectHeaders(ResponseInterface $response, array $headers = []): ResponseInterface
    {
        foreach ($headers as $name => $value) {
            $response = $response->withHeader($name, $value);
        }

        return $response;
    }
270865
protected function generateResponse(ResponseInterface $response): ArrivalBoardResponse
    {
        $json = $this->validateJson($response);
        if (isset($json['ArrivalBoard'])) {
            return ArrivalBoardResponse::createFromArray($json['ArrivalBoard']);
        }

        return new ArrivalBoardResponse();
    }
461803
public function toString(ResponseInterface $response)
    {
        $string = sprintf(
            "HTTP/%s %s %s\n",
            $response->getProtocolVersion(),
            $response->getStatusCode(),
            $response->getReasonPhrase()
        );

        $string .= $this->headersAndBody($response);

        return $string;
    }