Exemplo n.º 1
0
 /**
  * Sends response headers.
  *
  * @access  protected
  */
 public function sendHeaders()
 {
     // Send status header
     $protocol = $this->request->server('SERVER_PROTOCOL', 'HTTP/1.1');
     header($protocol . ' ' . $this->statusCode . ' ' . $this->statusCodes[$this->statusCode]);
     // Send content type header
     $contentType = $this->contentType;
     if (stripos($contentType, 'text/') === 0 || in_array($contentType, ['application/json', 'application/xml'])) {
         $contentType .= '; charset=' . $this->charset;
     }
     header('Content-Type: ' . $contentType);
     // Send other headers
     foreach ($this->headers as $name => $headers) {
         foreach ($headers as $value) {
             header($name . ': ' . $value, false);
         }
     }
     // Send cookie headers
     foreach ($this->cookies as $cookie) {
         setcookie($cookie['name'], $cookie['value'], $cookie['ttl'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
     }
 }
Exemplo n.º 2
0
 /**
  *
  */
 public function testServer()
 {
     $server = $this->getServerData();
     $request = new Request(['server' => $server]);
     $this->assertNull($request->server('bar'));
     $this->assertFalse($request->server('bar', false));
     $this->assertEquals('example.local', $request->server('HTTP_HOST'));
     $this->assertEquals($server, $request->server());
 }