Beispiel #1
0
 /**
  * Attempts to cache the sent entity by its last modification date.
  * @param  string|int|\DateTime  last modified time
  * @param  string  strong entity tag validator
  * @return bool
  */
 public function isModified($lastModified = NULL, $etag = NULL)
 {
     if ($lastModified) {
         $this->response->setHeader('Last-Modified', Helpers::formatDate($lastModified));
     }
     if ($etag) {
         $this->response->setHeader('ETag', '"' . addslashes($etag) . '"');
     }
     $ifNoneMatch = $this->request->getHeader('If-None-Match');
     if ($ifNoneMatch === '*') {
         $match = TRUE;
         // match, check if-modified-since
     } elseif ($ifNoneMatch !== NULL) {
         $etag = $this->response->getHeader('ETag');
         if ($etag == NULL || strpos(' ' . strtr($ifNoneMatch, ",\t", '  '), ' ' . $etag) === FALSE) {
             return TRUE;
         } else {
             $match = TRUE;
             // match, check if-modified-since
         }
     }
     $ifModifiedSince = $this->request->getHeader('If-Modified-Since');
     if ($ifModifiedSince !== NULL) {
         $lastModified = $this->response->getHeader('Last-Modified');
         if ($lastModified != NULL && strtotime($lastModified) <= strtotime($ifModifiedSince)) {
             $match = TRUE;
         } else {
             return TRUE;
         }
     }
     if (empty($match)) {
         return TRUE;
     }
     $this->response->setCode(IResponse::S304_NOT_MODIFIED);
     return FALSE;
 }
Beispiel #2
0
 /**
  * @deprecated
  */
 public static function date($time = NULL)
 {
     trigger_error('Method date() is deprecated, use Nette\\Http\\Helpers::formatDate() instead.', E_USER_DEPRECATED);
     return Helpers::formatDate($time);
 }
Beispiel #3
0
 /**
  * @deprecated
  */
 public static function date($time = NULL)
 {
     return Helpers::formatDate($time);
 }