Пример #1
0
 /**
  * @dataProvider providerParseIfMatch
  */
 public function testParseIfMatch($expected, $value)
 {
     $result = Header::parseIfMatch($value);
     $this->assertEquals($expected, $result);
 }
Пример #2
0
 /**
  * Gets the timestamp of the conditional modified since header
  * @return integer|null The timestamp if the header was set, null otherwise
  */
 public function getIfModifiedSince()
 {
     if (isset($this->ifModifiedSince)) {
         return $this->ifModifiedSince;
     }
     $header = $this->getHeader(Header::HEADER_IF_MODIFIED_SINCE);
     if (!$header) {
         return $this->ifModifiedSince = null;
     }
     return $this->ifModifiedSince = Header::parseTime($header);
 }
Пример #3
0
 public function testSetAndGetLastModified()
 {
     $time = time();
     $this->response->setLastModified($time);
     $header = $this->response->getHeader('Last-Modified');
     $this->assertNotNull($header);
     $this->assertEquals(Header::parseTime($time), $header);
     $this->assertEquals($time, $this->response->getLastModified());
     $this->response->setLastModified();
     $header = $this->response->getHeader('Last-Modified');
     $this->assertNull($header);
     $this->assertNull($this->response->getLastModified());
 }
Пример #4
0
 /**
  * Removes a header with the provided name
  * @param string $name Name of the header
  * @return null
  * @throws ZiboException when the provided name is empty or invalid
  */
 public function removeHeader($name)
 {
     if (!is_array($name)) {
         $name = array($name);
     }
     foreach ($name as $header) {
         $header = Header::parseName($header);
         if (isset($this->headers[$header])) {
             unset($this->headers[$header]);
         }
     }
 }
Пример #5
0
 /**
  * Sets the date the content was last modified
  * @param integer $timestamp Timestamp of the date
  * @return null
  */
 public function setLastModified($timestamp = null)
 {
     if ($timestamp === null) {
         $this->dateLastModified = null;
         $this->headers->removeHeader(Header::HEADER_LAST_MODIFIED);
         return;
     }
     if (!Number::isNumeric($timestamp, Number::NOT_NEGATIVE | Number::NOT_ZERO | Number::NOT_FLOAT)) {
         throw new ZiboException('Invalid date provided');
     }
     $this->dateLastModified = $timestamp;
     $this->headers->setHeader(Header::HEADER_LAST_MODIFIED, Header::parseTime($timestamp));
 }