Пример #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
 /**
  * Adds a header to this container
  * @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 setHeader
  */
 public function addHeader($header, $value = null)
 {
     if (!$header instanceof Header) {
         $header = new Header($header, $value);
     }
     $headerName = $header->getName();
     if ($headerName == Header::HEADER_CACHE_CONTROL) {
         // make sure the cache control array is in sync with the header
         $this->cacheControl = $this->parseCacheControl($header->getValue());
         $this->headers[$headerName] = $header;
     } elseif (isset($this->headers[$headerName])) {
         if (is_array($this->headers[$headerName])) {
             // already some headers set with this name, just add it
             $this->headers[$headerName][] = $header;
         } else {
             // already a header set with this name, convert to array and
             // add it
             $this->headers[$headerName] = array($this->headers[$headerName], $header);
         }
     } else {
         // no header set with this name
         $this->headers[$headerName] = $header;
     }
 }