Ejemplo n.º 1
0
 private function saveRateLimit(Github\Http\Response $response)
 {
     if (($previous = $response->getPrevious()) && $previous->isCode(Github\Http\Response::S304_NOT_MODIFIED)) {
         # Cached
         $response = $previous;
     }
     $this->session->rateLimit = $this->rateLimit = (object) ['limit' => $response->getHeader('X-RateLimit-Limit', '???'), 'remaining' => $response->getHeader('X-RateLimit-Remaining', '???'), 'reset' => $response->getHeader('X-RateLimit-Reset')];
 }
Ejemplo n.º 2
0
 /**
  * @return bool
  */
 protected function isCacheable(Response $response)
 {
     /** @todo Do it properly. Vary:, Pragma:, TTL...  */
     if (!$response->isCode(200)) {
         return FALSE;
     } elseif (preg_match('#max-age=0|must-revalidate#i', $response->getHeader('Cache-Control', ''))) {
         return FALSE;
     }
     return $response->hasHeader('ETag') || $response->hasHeader('Last-Modified');
 }