@param Response $response

@throws Code103ResponseException

@return bool
13852
public static function parseResponse(Response $response)
    {
        $jsonData = \GuzzleHttp\json_decode($response->getBody(), true);
        if (
            (isset($jsonData['errCode']) && 0 === $jsonData['errCode'])
            || (isset($jsonData['retcode']) && 0 === $jsonData['retcode'])
        ) {
            return true;
        }
        if (isset($jsonData['retcode']) && 103 === $jsonData['retcode']) {
            throw new Code103ResponseException($response);
        }

        return false;
    }
1358918
private function _parseResponse(Response $response)
    {
        switch ($this->_format) {
            case self::FORMAT_JSON:
                return json_decode($response, $this->_isJsonDecodeAssoc);
                break;
            default:
                return $response;
        }
    }
710190
protected function isJsonEncodable($response) : bool
    {
        if ($response instanceof ResponseInterface) {
            return false;
        }

        return (is_array($response) || is_object($response));
    }
165503
public static function canCacheResponse(ResponseInterface $response)
    {
        static $cacheCodes = [200, 203, 300, 301, 410];

        // Check if the response is cacheable based on the code
        if (!in_array((int) $response->getStatusCode(), $cacheCodes)) {
            return false;
        }

        // Make sure a valid body was returned and can be cached
        $body = $response->getBody();
        if ($body && (!$body->isReadable() || !$body->isSeekable())) {
            return false;
        }

        // Never cache no-store resources (this is a private cache, so private
        // can be cached)
        if (self::getDirective($response, 'no-store')) {
            return false;
        }

        // Don't fool with Content-Range requests for now
        if ($response->hasHeader('Content-Range')) {
            return false;
        }

        $freshness = self::getFreshness($response);

        return $freshness === null                    // No freshness info.
            || $freshness >= 0                        // It's fresh
            || $response->hasHeader('ETag')           // Can validate
            || $response->hasHeader('Last-Modified'); // Can validate
    }
163062
public function isValid($response)
    {
        if (is_null($this->secretKey))
            throw new \Exception('You must set your secret key');

        if (empty($response)) {

            $this->errorCodes = array('internal-empty-response');

            return false;
        }

        $params = array(
            'secret'   => $this->secretKey,
            'response' => $response,
            'remoteip' => $this->remoteIp,
        );

        $url = self::VERIFY_URL.'?'.http_build_query($params);

        if (function_exists('curl_version'))
        {
            $curl = curl_init($url);
            curl_setopt($curl, CURLOPT_HEADER, false);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curl, CURLOPT_TIMEOUT, $this->verifyTimeout);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            $response = curl_exec($curl);
        }
        else
        {
            $response = file_get_contents($url);
        }

        if (empty($response) || is_null($response) || !$response)
        {
            return false;
        }

        $json = json_decode($response, true);

        if (isset($json['error-codes']))
        {
            $this->errorCodes = $json['error-codes'];
        }

        return $json['success'];
    }
687765
protected function isHtmlResponse($response)
    {
        return strtolower(substr($response, 0, strlen('<!doctype html'))) === '<!doctype html'
            || strtolower(substr($response, 0, strlen('<html'))) === '<html'
            || strtolower(substr($response, 0, strlen('<body'))) === '<body';
    }
911597
private static function checkResponse(Response $response)
    {
        $statusCode = $response->getStatusCode();

        if ($statusCode >= 400 && $statusCode < 600) {
            $reason = $response->getReasonPhrase();
            $body = json_decode($response->getBody());

            if (isset($body->error->exception[0]->message)) {
                $reason = $body->error->exception[0]->message;
            }

            throw new FenrirApiException($statusCode, $reason);
        }
    }
125590
protected function checkResponseErrors(ResponseInterface $response)
	{
		$status = intval($response->getStatusCode());

		if ($status === 200) return;

		switch ($status) {
			case 401:
				throw new AuthorizationException($response);
			default:
				throw new RequestException($response);
		}
	}
1076696
protected function checkResponseFormat(Response $response)
    {
        set_error_handler(function() { /* ignore errors */ });
        $arr = json_decode($response->getBody(), true, 512, 1);
        restore_error_handler();

        if (isset($arr['error'])) {
            throw new DiffbotException('Diffbot returned error ' . $arr['errorCode'] . ': ' . $arr['error']);
        }

        $required = [
            'objects' => 'Objects property missing - cannot extract entity values',
            'request' => 'Request property not found in response!'
        ];

        foreach ($required as $k=>$v) {
            if (!isset($arr[$k])) {
                throw new DiffbotException($v);
            }
        }

    }
211000
protected function handleResponse(Response $response)
    {
        $statusCode = $response->getStatusCode();

        switch ($statusCode) {
            case 401:
                $response = $this->processNotAuthorized();
                break;
        }

        return $response;
    }
280813
private static function isRetryableServerError(\GuzzleHttp\Psr7\Response $response)
    {
        if ($response) {
            $statusCode = $response->getStatusCode();
            return $statusCode > 500 && $statusCode < 600;
        } else {
            return false;
        }
    }
93467
protected function needToUpdateResponse(Response $response)
    {
        $isJsonResponse = $response instanceof JsonResponse || $response->headers->contains('content-type',
                'application/json');

        return $isJsonResponse && !$this->storage->isEmpty();
    }
1133405
public function checkResponse($response) {
    if (!is_array($response)) {
      return FALSE;
    }

    $responseParams = array();
    foreach ($this->responseFields as $k => $mandatory) {
      if (isset($response[$k])) {
        $responseParams[$k] = $response[$k];
      }
      elseif (!isset($response[$k]) && $mandatory) {
        throw new \Exception('expected response field ' . $k . ' is missing');
      }
    }

    return $responseParams;
  }
926824
private function parseRateLimitFromResponse(Response $response)
    {
        $rateLimitHeaders = array_filter([
            $response->getHeader('X-Rate-Limit-Limit'),
            $response->getHeader('X-Rate-Limit-Remaining'),
            $response->getHeader('X-Rate-Limit-Reset')
        ]);

        if (count($rateLimitHeaders) == 3) {
            $rateLimitClass = new ReflectionClass(RateLimit::class);
            $this->rate_limit = $rateLimitClass->newInstanceArgs($rateLimitHeaders);
        }
    }
878321
public function handleResponse(Request $request, Response $response)
    {
        if ($response->getStatusCode() == 422) {
            $errors = $response->getOriginalContent()['validation_errors'];

            throw new HttpResponseException(
                redirect()->back()->withInput($request->input())->withErrors($errors)
            );
        }

        if ($response->getStatusCode() == 403) {
            abort(403);
        }

        return $response->isNotFound() ? abort(404) : $response->getOriginalContent();
    }
1137806
protected function filterResponse(Response $response)
    {
        $event = new FilterResponseEvent($this->app, $response);
        $this->event_dispatcher->dispatch(DietcubeEvents::FILTER_RESPONSE, $event);

        return $this->finishRequest($event->getResponse());
    }
187222
protected function respond($response)
    {
        $success = Arr::get($response, 'success');

        return $this->mapResponse($success, $response);
    }