Пример #1
0
 function postExecute(HeaderManager $headers)
 {
     //If people dont utilise the checks until now this will catch it at the end of the request
     if ($headers->status == 200) {
         if (isset($headers['Last-Modified'])) {
             //Check if the user sent a If-Modified-Since header in their request
             $ims = \Radical\Web\Page\Request::header('If-Modified-Since');
             if ($ims) {
                 //Parse the time in the last modified sent from the page handler
                 $lmts = strtotime($headers['Last-Modified']);
                 //If the user has an unmodified version (aparently) based on last modifed dates
                 if ($lmts <= strtotime($ims)) {
                     $this->notModified($headers);
                 }
             }
         } else {
             //If no Last-Modified specified
             //Look for etag in request
             $et = \Radical\Web\Page\Request::header('If-None-Match');
             if (strlen($et) >= 2) {
                 if (substr($et, 0, 2) == 'W/') {
                     $et = substr($et, 2);
                 }
             }
             if (isset($headers['ETag'])) {
                 if ($et == $headers['ETag']) {
                     $this->notModified($headers);
                 }
             } else {
                 $hash = md5(md5(ob_get_contents(), true) . session_id());
                 if ($hash == substr($et, 1, -1)) {
                     $this->notModified($headers);
                 } else {
                     $headers->setEtag($hash);
                 }
             }
         }
     }
 }
Пример #2
0
 static function fromRequest()
 {
     $url = Request::getUrl();
     return static::fromURL($url);
 }