Esempio n. 1
0
 /**
  * Send HTTP headers
  *
  * @param DispatcherResponseInterface $response
  * @throws \RuntimeException If the headers have already been send
  * @return DispatcherResponseTransportAbstract
  */
 public function sendHeaders(DispatcherResponseInterface $response)
 {
     if (!headers_sent($file, $line)) {
         //Send the status header
         header(sprintf('HTTP/%s %d %s', $response->getVersion(), $response->getStatusCode(), $response->getStatusMessage()));
         //Send the other headers
         $headers = explode("\r\n", trim((string) $response->getHeaders()));
         foreach ($headers as $header) {
             header($header, false);
         }
     } else {
         throw new \RuntimeException(sprintf('Headers already send (output started at %s:%s', $file, $line));
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * Send HTTP headers
  *
  * @param DispatcherResponseInterface $response
  * @return DispatcherResponseTransportAbstract
  */
 public function sendHeaders(DispatcherResponseInterface $response)
 {
     if (!headers_sent()) {
         //Send the status header
         header(sprintf('HTTP/%s %d %s', $response->getVersion(), $response->getStatusCode(), $response->getStatusMessage()));
         //Send the other headers
         $headers = explode("\r\n", trim((string) $response->headers));
         foreach ($headers as $header) {
             header($header, false);
         }
         //Send the cookies
         foreach ($response->headers->getCookies() as $cookie) {
             setcookie($cookie->name, $cookie->value, $cookie->expire, $cookie->path, $cookie->domain, $cookie->isSecure(), $cookie->isHttpOnly());
         }
     }
     return $this;
 }