Symfony\Component\HttpFoundation\ResponseHeaderBag::allPreserveCase PHP Method

allPreserveCase() public method

Returns the headers, with original capitalizations.
public allPreserveCase ( ) : array
return array An array of headers
    public function allPreserveCase()
    {
        $headers = array();
        foreach ($this->all() as $name => $value) {
            $headers[isset($this->headerNames[$name]) ? $this->headerNames[$name] : $name] = $value;
        }

        return $headers;
    }

Usage Example

Example #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;
 }
All Usage Examples Of Symfony\Component\HttpFoundation\ResponseHeaderBag::allPreserveCase