Check if the request is cachable following to the RFC2616
https://www.ietf.org/rfc/rfc2616.txt

@param  Response $response
@return boolean
432586
protected function isRequestCachable(Response $response)
    {
        if (!in_array($this->getMethod(), array('GET', 'HEAD'))) {
            return false;
        }

        if ($response->headers->hasCacheControlDirective('no-cache') ||
            'no-cache' == $response->headers->get('Pragma')
        ) {
            return false;
        }

        return true;
    }
1311666
public function isAuthorise($response){
        $result = false;
        $hasError = $this->isError($response);
        $isApprove = $this->isApprove($response);

        if(!$hasError && $isApprove){
            $result = true;
        }

        return $result;
    }
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';
    }
390269
private function isCacheable($method, $uri, array $options, $response)
    {
        /** @var ResponseInterface $statusCode */
        $statusCode = $response->getStatusCode();

        //cache only 2** responses
        if ($statusCode < 200 || $statusCode >= 300) {
            return false;
        }

        //GET is always safe to cache
        if ('GET' === $method) {
            return true;
        }

        //POST may be cached for certain endpoints only (forgive us Roy Fielding)
        if ('POST' === $method) {
            return in_array($uri, self::CACHEABLE_POST_ENDPOINTS);
        }

        //assume not cacheable in all other cases
        return false;
    }
590385
protected function getCacheTtl(Response $response)
    {
        if ($this->useHeaderTtl && $response->hasHeader('Cache-Control')) {
            $cacheControl =  $response->getHeader('Cache-Control')[0];

            if (preg_match('`max-age=(\d+)`', $cacheControl, $match)) {
                return intval($match[1]);
            }
        }

        return $this->defaultTtl;
    }
1089584
private function isSuccessful(Response $response): bool
    {
        if ($response->statusCode()->value() !== 200) {
            return false;
        }

        $json = Json::decode((string) $response->body());

        return count($json['errors']) === 0;
    }
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'];
    }
1302118
public static function enabled_for($response)
    {
        $contentType = $response->getHeader("Content-Type");

        // Disable content negotiation for other content types
        if ($contentType
            && substr($contentType, 0, 9) != 'text/html'
            && substr($contentType, 0, 21) != 'application/xhtml+xml'
        ) {
            return false;
        }

        if (ContentNegotiator::getEnabled()) {
            return true;
        } else {
            return (substr($response->getBody(), 0, 5) == '<' . '?xml');
        }
    }
633055
protected function isAnHtmlResponse(Response $response)
    {
        $type = $response->headers->get('Content-Type');

        return strtolower(strtok($type, ';')) === 'text/html';
    }
124569
protected function buildCacheDirectives($response)
    {
        $cacheControlHeader = null;
        if ($response->hasHeader('cache-control')) {
            $cacheControlHeader = $this->parseHeader($response->getHeader('cache-control'));
            $cacheControlHeader = current($cacheControlHeader);
            $cacheControlHeader = (isset($cacheControlHeader['max-age'])?$cacheControlHeader['max-age']:null);
        }

        $expiresHeader = null;
        if ($response->hasHeader('expires')){
            $expiresHeader = implode(' ',array_column($this->parseHeader($response->getHeader('expires')),0));
        }

        return array_filter([
            'maxAge'=>$cacheControlHeader,
            'expires'=>$expiresHeader,
        ]);
    }
285238
public function isBearer($response)
	{	
     	if (!isset($response->token_type)) {
    		return false;
    	}

    	if ($response->token_type == 'bearer') {
    		return $response->access_token;
    	}
	}
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;
    }
272694
protected function saveCachedView(Response $response)
    {
        if (config('sitemap.cache_enabled')) {
            $key = $this->getCacheKey();

            $content = $response->getOriginalContent()->render();

            if (!$this->cache->get($key)) {
                $this->cache->put($key, $content, config('sitemap.cache_length'));
            }
        }
    }
240355
public static function privateNoExpireCache(
        ResponseInterface $response,
        /*# int */ $cacheTime = 120
    )/*# : ResponseInterface */ {
        $maxAge = $cacheTime * 60;
        return $response
            ->withAddedHeader('Cache-Control', "private, max-age={$maxAge}, pre-check={$maxAge}")
            ->withAddedHeader('Last-Modified', self::timeStamp());
    }
1194711
private function isReferrerAble($response)
    {
        if (!Response::isOk($response)) {
            return false;
        }
        $type = $response->getHeader('Content-Type');
        if (!$type || $type === 'text/html') {
            return true;
        }
        return false;
    }
1316579
private function cacheVary(
        RequestInterface $request,
        ResponseInterface $response
    ) {
        $key = $this->getVaryKey($request);
        $this->cache->save($key, $this->normalizeVary($response), $this->getTtl($response));
    }
497029
protected function encrypt(Response $response)
    {
        foreach ($response->headers->getCookies() as $cookie) {
            if ($this->isDisabled($cookie->getName())) {
                continue;
            }

            $response->headers->setCookie($this->duplicate(
                $cookie, $this->encrypter->encrypt($cookie->getValue(), static::serialized($cookie->getName()))
            ));
        }

        return $response;
    }