@param ResponseInterface $response

@return array
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);
    }
383773
private function decorateResponse(ResponseInterface $response)
    {
        if ($response instanceof Http\Response) {
            return $response;
        }

        return new Http\Response($this, $response);
    }
1342830
protected function normalizeResponse(ResponseInterface $response)
    {
        if (!is_null($this->normalizer)) {
            return $this->normalizer->normalize($response);
        }

        //default responsen is decoded json
        return $response->json();
    }
584862
private function getOptions(MethodInterface $method)
    {
        if ($method->getMethod() == $method::GET) {
            return [
                'query' => $method->getAttributes(),
            ];
        }

        return [
            'headers' => [
                'Content-Type' => 'application/json',
            ],
            'body' => json_encode(
                $this->prepareAttributes($method->getAttributes()),
                JSON_FORCE_OBJECT
            )
        ];
    }
542236
public function buildData(ResponseInterface $response)
    {
        $data = new \stdClass();
        $data->apiVersion = $response->getApiVersion()->getValue();
        $data->method = $response->getHttpMethod()->getValue();

        $data->params = new \stdClass();
        /** @var Crak\Component\RestNormalizer\ParameterInterface $parameter */
        foreach ($response->getParameters() as $parameter) {
            $values = $parameter->getValues();
            $nbValues = count($values);

            $plainValues = null;
            if ($nbValues === 1) {
                $plainValues = $values->first()->getValue();
            } else if ($nbValues > 1) {
                foreach ($values as $value) {
                    $plainValues[] = $value->getValue();
                }
            }

            $data->params->{$parameter->getId()->getValue()} = $plainValues;
        }

        return $data;
    }
1115719
private function parseResponse(ResponseInterface $response = null): array
    {
        $body = $response
            ? (string) $response->getBody()
            : null;

        return $body
            ? guzzle_json_decode($body, true)
            : [];
    }
633357
public function getParametersFromResponse(ResponseInterface $response)
    {
        $contents = $response->getBody()->getContents();

        $parameters = [];

        parse_str($contents, $parameters);

        return $parameters;
    }
688999
protected function encodeSetCookieHeader(ResponseInterface $response)
    {
        $cookies = CookieCollection::createFromHeader($response->getHeader('Set-Cookie'));
        $header = [];
        foreach ($cookies as $cookie) {
            if (in_array($cookie->getName(), $this->cookieNames, true)) {
                $value = $this->_encrypt($cookie->getValue(), $this->cipherType);
                $cookie = $cookie->withValue($value);
            }
            $header[] = $cookie->toHeaderValue();
        }

        return $response->withHeader('Set-Cookie', $header);
    }
631255
public static function getContent(ResponseInterface $response)
    {
        if ($response->getStatusCode() === 204) {
            return [];
        }

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

        if (!$body) {
            return [];
        }

        if (strpos($response->getHeaderLine('Content-Type'), 'application/json') !== 0) {
            throw new DecodingFailedException('The content type header was not application/json.');
        }

        return self::jsonDecode($body);
    }
1298208
private function getMaxAge(ResponseInterface $response)
    {
        if (!in_array('max-age', $this->config['respect_response_cache_directives'], true)) {
            return $this->config['default_ttl'];
        }

        // check for max age in the Cache-Control header
        $maxAge = $this->getCacheControlDirective($response, 'max-age');
        if (!is_bool($maxAge)) {
            $ageHeaders = $response->getHeader('Age');
            foreach ($ageHeaders as $age) {
                return $maxAge - ((int) $age);
            }

            return (int) $maxAge;
        }

        // check for ttl in the Expires header
        $headers = $response->getHeader('Expires');
        foreach ($headers as $header) {
            return (new \DateTime($header))->getTimestamp() - (new \DateTime())->getTimestamp();
        }

        return $this->config['default_ttl'];
    }
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;
    }
870616
protected function getParameters(RequestInterface $request, ResponseInterface $response = null)
    {
        $params = [];
        $result = '';

        $keys = array_intersect($this->context, $this->availableParameters);

        foreach ($keys as $key) {
            switch ($key) {
                case 'method':
                    $result = $request->getMethod();
                    break;
                case 'url':
                    $result = $request->getUri()->__toString();
                    break;
                case 'request_version':
                    $result = $request->getProtocolVersion();
                    break;
                case 'response_version':
                    $result = $response ? $response->getProtocolVersion() : 'NULL';
                    break;
                case 'host':
                    $result = $request->getUri()->getHost();
                    break;
                case 'hostname':
                    $result = gethostname();
                    break;
                case 'status_code':
                    $result = $response ? $response->getStatusCode() : 'NULL';
                    break;
                case 'phrase':
                    $result = $response ? $response->getReasonPhrase() : 'NULL';
                    break;
            }

            $params[$key] = (string) $result ?: '';
        }

        return $params;
    }
112516
public static function responseToJson(ResponseInterface $response)
    {
        $contents = $response->getBody()->getContents();
        if (empty($contents)) {
            return [];
        }

        return \GuzzleHttp\json_decode($contents, true);
    }
734865
private function getLoggableResponse(ResponseInterface $response)
    {
        $body = $response->getBody()->__toString();

        return $response->getStatusCode() . ' / '
            . \strlen($body) > 5000 ? '--VERY LONG CONTENTS--' : preg_replace('|\s+|', ' ', $body);
    }
277369
public static function fromResponse(ResponseInterface $response)
    {
        $responseBody = (string) $response->getBody();
        if (empty($responseBody)) {
            return new self($response->getStatusCode(), $response->getReasonPhrase());
        }

        $decodedBody = json_decode($responseBody, true);
        if (!isset($decodedBody['error'])) {
            return new self($response->getStatusCode(), $response->getReasonPhrase());
        }

        $error = $decodedBody['error'];

        return new self($response->getStatusCode(), $error['message'], $error['type'], $error);
    }
871800
protected function _unserializeResponseBody(ResponseInterface $response) {

		$body = (string) $response->getBody();
		$contentType = $response->getHeaderLine('Content-type');

		try {
			if(false !== stripos($contentType, $this->dataType)
				&& isset($this->unserializers[$this->dataType])) {
				/** @var UnserializerInterface $unserializer */
				$unserializer = \Yii::createObject($this->unserializers[$this->dataType]);
				if($unserializer instanceof UnserializerInterface) {
					return $unserializer->unserialize($body, false);
				}
			}

			return $body;

		} catch(InvalidParamException $e) {

			return $body;
		}
	}
507223
public static function decode(ResponseInterface $response): array
    {
        $contents = $response->getBody()->getContents();
        $decoded = json_decode($contents, true);
        $response->getBody()->rewind();

        if (json_last_error() !== JSON_ERROR_NONE || ! is_array($decoded)) {
            throw new JsonException(json_last_error_msg());
        }

        return $decoded;
    }