/** * Returns whether the entity tags sent with the request match that * given by the response. * * @return bool */ protected function matchEntityTags() { if ($responding = $this->response->getHeader("ETag")) { $requested = $this->request->getETags(); return $requested && (in_array($responding, $requested) || in_array("*", $requested)); } return false; }
/** * Determines if the Response validators (ETag, Last-Modified) match * a conditional value specified in the Request. * * If the Response is not modified, it sets the status code to 304 and * removes the actual content by calling the setNotModified() method. * * @param Request $request A Request instance * * @return bool true if the Response validators match the Request, false otherwise */ public function isNotModified(Request $request) { if (!$request->isMethodSafe()) { return false; } $notModified = false; $lastModified = $this->headers->get('Last-Modified'); $modifiedSince = $request->headers->get('If-Modified-Since'); if ($etags = $request->getETags()) { $notModified = in_array($this->getEtag(), $etags) || in_array('*', $etags); } if ($modifiedSince && $lastModified) { $notModified = strtotime($modifiedSince) >= strtotime($lastModified) && (!$etags || $notModified); } if ($notModified) { $this->setNotModified(); } return $notModified; }