Process the rate limit.

@param ResponseInterface $response
351119
private function processThrottleData(ResponseInterface $response)
    {
        if (empty($rateLimit = $response->getHeader('X-RateLimit-Limit'))) {
            return;
        }

        if (empty($remaining = $response->getHeader('X-RateLimit-Remaining'))) {
            return;
        }

        if (!empty($reset = $response->getHeader('X-RateLimit-Reset'))) {
            $this->rateLimit->setEndOfThrottle(intval($reset[0]));
        } else {
            $this->rateLimit->setEndOfThrottle(null);
        }

        $this->rateLimit->setMaxPerMinute(intval($rateLimit[0]))->setRemaining(intval($remaining[0]));
    }
460445
public function run(RequestInterface $request, ResponseInterface $response): void
    {
        $this->doRun($request, $response);
        $response->output();
    }
1337846
public function processResponse(ResponseInterface $response)
    {

        $body = $response->getBody();

        $object = json_decode($body);
        if (json_last_error() === JSON_ERROR_NONE) {
            // JSON is valid
            if (property_exists($object, '_embedded') && property_exists($object->_embedded, 'items')) {
                $return = $object->_embedded->items;
            } elseif (property_exists($object, 'error')) {
                if (is_array($object->message)) {
                    foreach ($object->message as $message) {
                        $output .= $message;
                    }
                    throw new \Exception($output);
                } else {
                    throw new \Exception($object->message);
                }
            } else {
                $return = $object;
            }
        } else {
            $return = $body;
        }

        return $return;
    }
997124
function parseRateLimit(Response $response) {
        $newRateLimit = \GithubService\RateLimit::createFromResponse($response);
        if ($newRateLimit != null) {
            $this->rateLimit = $newRateLimit;
        }
    }
897305
protected function handleTokenResponse(ResponseInterface $response)
    {
        $statusCode = $response->getStatusCode();
        if (500 <= $statusCode) {
            $e = new ServiceUnavailableException();
            $e->setResponse($response);
            throw $e;
        }

        $contentTypes = $response->getHeader('content-type');
        if (empty($contentTypes) || (0 !== strpos($contentTypes[0], 'application/json') && 0 !== strpos($contentTypes[0], 'text/javascript'))) {
            $e = new UnknownContentTypeException();
            $e->setResponse($response);
            if (!empty($contentTypes)) {
                $e->setContentType($contentTypes[0]);
            }
            throw $e;
        }

        $data = json_decode($response->getBody()->getContents(), true);
        if (200 !== $statusCode) {
            $e = new RequestTokenException();
            $e->setResponse($response);

            if (isset($data['error'])) {
                $e->setError(is_array($data['error']) ? json_encode($data['error']) : $data['error']);
            }

            if (isset($data['error_description'])) {
                $e->setDescription($data['error_description']);
            }

            if (isset($data['error_uri'])) {
                $e->setUri($data['error_uri']);
            }

            throw $e;
        }

        if (isset($data['access_token'])) {
            $this->setAccessToken($data['access_token']);
        }

        return $data;
    }
961781
protected function dispatchOnResponse(ResponseInterface $response): ResponseInterface
    {
        $responseEvent = new ResponseEvent($response);
        $this->dispatcher->dispatch($this->responseEvent, $responseEvent);

        return $responseEvent->getResponse();
    }
311169
private function validateResponse(ResponseInterface $response)
    {
        if ($response->getStatusCode() !== 200) {
            $responseData = json_decode((string) $response->getBody(), true);
            $code = isset($responseData['error']['code']) ? $responseData['error']['code'] : 0;
            $message = isset($responseData['error']['message']) ? $responseData['error']['message'] : $response->getReasonPhrase();

            throw new ApiException($message, $code, $responseData);
        }
    }
128866
private function handleRequest(RequestInterface $request, ResponseInterface $response): void
    {
        foreach ($this->routes as $route) {
            $routeMatch = $route->matches($request);

            if ($routeMatch === null) {
                continue;
            }

            $controllerClass = $routeMatch->getControllerClassName();
            $controller = new $controllerClass();

            /** @var ControllerInterface $controller */
            $controller->processRequest($this, $request, $response, $routeMatch->getAction(), $routeMatch->getParameters());

            return;
        }

        $response->setStatusCode(new StatusCode(StatusCode::NOT_FOUND));
    }
847695
protected function handleResponse(ResponseInterface $response)
    {
        $contents = $response->getBody()->getContents();
        try
        {
            return $contents ? \GuzzleHttp\json_decode($contents) : null;
        }
        catch (\InvalidArgumentException $e)
        {
            throw new Exception('Unable to decode PDF Generator API response', $e->getCode(), $e);
        }
    }
1005298
public static function getApiLimit(ResponseInterface $response)
    {
        $remainingCalls = self::getHeader($response, 'X-RateLimit-Remaining');

        if (null !== $remainingCalls && 1 > $remainingCalls) {
            throw new ApiLimitExceedException($remainingCalls);
        }

        return $remainingCalls;
    }
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;
    }
1332088
public function sendHeaders( ResponseInterface $response ) {
		// Status
		header( sprintf(
			'HTTP/%s %s %s',
			$response->getProtocolVersion(),
			$response->getStatusCode(),
			$response->getReasonPhrase()
		) );

		// Headers
		foreach ( $response->getHeaders() as $name => $values ) {
			foreach ( $values as $value ) {
				header( sprintf( '%s: %s', $name, $value ), false );
			}
		}
	}
772930
protected function processResult(Response $response)
    {
        $content = $response->getContent();
        if (strpos($content, "callback(") === 0) {
            $count = 0;
            $jsonData = preg_replace('/^callback\(\s*(\\{.*\\})\s*\);$/is', '\1', $content, 1, $count);
            if ($count === 1) {
                $response->setContent($jsonData);
            }
        }
    }
226264
private function canSave(RequestInterface $request, ResponseInterface $response)
    {
        if ($request->getMethod() !== 'GET') {
            return false;
        }

        if ($response->getStatusCode() !== 200) {
            return false;
        }

        if (!$this->appendQuery && !empty($request->getUri()->getQuery())) {
            return false;
        }

        if ($response->hasHeader('location')) {
            return false;
        }

        $cacheControl = $response->getHeaderLine('Cache-Control');

        if ($cacheControl && (stripos($cacheControl, 'no-cache') !== false || stripos($cacheControl, 'no-store') !== false)) {
            return false;
        }

        return true;
    }
405869
public function canResponseSatisfyRequest(RequestInterface $request, Response $response)
    {
        $responseAge = $response->calculateAge();
        $reqc = $request->getHeader('Cache-Control');
        $resc = $response->getHeader('Cache-Control');

        // Check the request's max-age header against the age of the response
        if ($reqc && $reqc->hasDirective('max-age') &&
            $responseAge > $reqc->getDirective('max-age')) {
            return false;
        }

        // Check the response's max-age header
        if ($response->isFresh() === false) {
            $maxStale = $reqc ? $reqc->getDirective('max-stale') : null;
            if (null !== $maxStale) {
                if ($maxStale !== true && $response->getFreshness() < (-1 * $maxStale)) {
                    return false;
                }
            } elseif ($resc && $resc->hasDirective('max-age')
                && $responseAge > $resc->getDirective('max-age')
            ) {
                return false;
            }
        }

        if ($this->revalidation->shouldRevalidate($request, $response)) {
            try {
                return $this->revalidation->revalidate($request, $response);
            } catch (CurlException $e) {
                $request->getParams()->set('cache.hit', 'error');
                return $this->canResponseSatisfyFailedRequest($request, $response);
            }
        }

        return true;
    }
1120940
private function processResponse(ResponseInterface $response)
    {
        if($response->getStatusCode() != 200){
            throw new YouHostingException("The API returned with a non-successful error code: ".$response->getStatusCode());
        }

        $json = $response->json();

        if(!empty($json['error'])){
            throw new YouHostingException($json['error']['message'], $json['error']['code']);
        }

        return $json['result'];
    }
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;
    }