Cake\Network\Response::sendHeaders PHP Method

sendHeaders() public method

Sends the HTTP headers and cookies.
public sendHeaders ( ) : void
return void
    public function sendHeaders()
    {
        $file = $line = null;
        if (headers_sent($file, $line)) {
            Log::warning("Headers already sent in {$file}:{$line}");
            return;
        }
        $codeMessage = $this->_statusCodes[$this->_status];
        $this->_setCookies();
        $this->_sendHeader("{$this->_protocol} {$this->_status} {$codeMessage}");
        $this->_setContentType();
        foreach ($this->_headers as $header => $values) {
            foreach ((array) $values as $value) {
                $this->_sendHeader($header, $value);
            }
        }
    }

Usage Example

Beispiel #1
1
 /**
  * Filters the cake response to the BrowserKit one.
  *
  * @param \Cake\Network\Response $response Cake response.
  * @return \Symfony\Component\BrowserKit\Response BrowserKit response.
  */
 protected function filterResponse($response)
 {
     $this->cake['response'] = $response;
     foreach ($response->cookie() as $cookie) {
         $this->getCookieJar()->set(new Cookie($cookie['name'], $cookie['value'], $cookie['expire'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httpOnly']));
     }
     $response->sendHeaders();
     return new BrowserKitResponse($response->body(), $response->statusCode(), $response->header());
 }
All Usage Examples Of Cake\Network\Response::sendHeaders