Пример #1
0
 public function testConstruct()
 {
     $name = 'Name';
     $value = 'value';
     $header = new Header($name, $value);
     $this->assertEquals($name, $header->getName());
     $this->assertEquals($value, $header->getValue());
 }
Пример #2
0
 /**
  * Sets a header to this container, any existing headers with the same
  * name will be overwritten
  * @param string|Header $header Name of the header or a Header instance
  * @param string|null $value The value of the header or null if a Header
  * instance is provided
  * @return null
  * @see addHeader
  */
 public function setHeader($header, $value = null)
 {
     if (!$header instanceof Header) {
         $header = new Header($header, $value);
     }
     if (isset($this->headers[$header->getName()])) {
         unset($this->headers[$header->getName()]);
     }
     $this->addHeader($header);
 }
Пример #3
0
 /**
  * Adds a HTTP header.
  *
  * On Wikipedia you can find a {@link http://en.wikipedia.org/wiki/List_of_HTTP_headers list of HTTP headers}.
  * If a Locaton header is added, the status code will also be automatically
  * set to 302 Found if the current status code is 200 OK.
  * @param string $name the name of the header
  * @param string $value the value of the header
  * @return null
  * @throws zibo\ZiboException when the provided name is empty or invalid
  * @throws zibo\ZiboException when the provided value is empty or invalid
  * @see setHeader()
  */
 public function addHeader($name, $value)
 {
     $header = new Header($name, $value);
     if ($header->getName() == Header::HEADER_LOCATION && !$this->willRedirect()) {
         $this->setStatusCode(self::STATUS_CODE_FOUND);
     }
     $this->headers->addHeader($header);
 }