allPreserveCase() public method

Returns the headers, with original capitalizations.
public allPreserveCase ( ) : array
return array An array of headers
Beispiel #1
0
 /**
  * Sends HTTP headers.
  *
  * @return Response
  */
 public function sendHeaders()
 {
     // headers have already been sent by the developer
     if (headers_sent()) {
         return $this;
     }
     // status
     header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText));
     // headers
     foreach ($this->headers->allPreserveCase() as $name => $values) {
         foreach ($values as $value) {
             header($name . ': ' . $value, false);
         }
     }
     // cookies
     foreach ($this->headers->getCookies() as $cookie) {
         setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
     }
     return $this;
 }
 public function testToStringDoesntMessUpHeaders()
 {
     $headers = new ResponseHeaderBag();
     $headers->set('Location', 'http://www.symfony.com');
     $headers->set('Content-type', 'text/html');
     (string) $headers;
     $allHeaders = $headers->allPreserveCase();
     $this->assertEquals(array('http://www.symfony.com'), $allHeaders['Location']);
     $this->assertEquals(array('text/html'), $allHeaders['Content-type']);
 }
Beispiel #3
0
 /**
  * Sends HTTP headers.
  *
  * @return Response
  */
 public function sendHeaders()
 {
     // headers have already been sent by the developer
     if (headers_sent()) {
         return $this;
     }
     if (!$this->headers->has('Date')) {
         $this->setDate(\DateTime::createFromFormat('U', time()));
     }
     // headers
     foreach ($this->headers->allPreserveCase() as $name => $values) {
         foreach ($values as $value) {
             header($name . ': ' . $value, false, $this->statusCode);
         }
     }
     // status
     header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
     // cookies
     foreach ($this->headers->getCookies() as $cookie) {
         if ($cookie->isRaw()) {
             setrawcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
         } else {
             setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
         }
     }
     return $this;
 }
    /**
     * @covers Symfony\Component\HttpFoundation\ResponseHeaderBag::allPreserveCase
     * @dataProvider provideAllPreserveCase
     */
    public function testAllPreserveCase($headers, $expected)
    {
        $bag = new ResponseHeaderBag($headers);

        $this->assertEquals($expected, $bag->allPreserveCase(), '->allPreserveCase() gets all input keys in original case');
    }