isMethodSafe() 공개 정적인 메소드

Checks whether the method is safe or not.
public static isMethodSafe ( ) : boolean
리턴 boolean
예제 #1
0
파일: Response.php 프로젝트: mitap45/Daily
 /**
  * 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
  *
  * @api
  */
 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;
 }
예제 #2
0
 /**
  * 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
  *
  * @api
  */
 public function isNotModified(Request $request)
 {
     if (!$request->isMethodSafe()) {
         return false;
     }
     $lastModified = $request->headers->get('If-Modified-Since');
     $notModified = false;
     if ($etags = $request->getEtags()) {
         $notModified = (in_array($this->getEtag(), $etags) || in_array('*', $etags)) && (!$lastModified || $this->headers->get('Last-Modified') == $lastModified);
     } elseif ($lastModified) {
         $notModified = $lastModified == $this->headers->get('Last-Modified');
     }
     if ($notModified) {
         $this->setNotModified();
     }
     return $notModified;
 }