renderHeaders() public méthode

Renders the HTTP headers - including the status header - of this response
public renderHeaders ( ) : array
Résultat array The HTTP headers
 /**
  * Just return the processed value
  *
  * @return mixed
  */
 public function evaluate()
 {
     $httpResponse = new Response();
     $httpResponse->setStatus($this->getStatusCode());
     $httpResponse->setHeaders(new Headers());
     foreach ($this->getHeaders() as $name => $value) {
         $httpResponse->setHeader($name, $value);
     }
     return implode("\r\n", $httpResponse->renderHeaders()) . "\r\n\r\n";
 }
 /**
  * @test
  */
 public function additionalHeadersCanBeSetAndRetrieved()
 {
     $response = new Response();
     $response->setStatus(123, 'Custom Status');
     $response->setHeader('MyHeader', 'MyValue');
     $response->setHeader('OtherHeader', 'OtherValue');
     $expectedHeaders = ['HTTP/1.1 123 Custom Status', 'Content-Type: text/html; charset=UTF-8', 'MyHeader: MyValue', 'OtherHeader: OtherValue'];
     $this->assertEquals($expectedHeaders, $response->renderHeaders());
 }
Exemple #3
0
 /**
  * @test
  */
 public function multipleHeadersCanBeSetAsArray()
 {
     $response = new Response();
     $response->setStatus(123, 'Custom Status');
     $response->setHeader('MyHeader', ['MyValue-1', 'MyValue-2', 'MyValue-3']);
     $expectedHeaders = ['HTTP/1.1 123 Custom Status', 'Content-Type: text/html; charset=UTF-8', 'MyHeader: MyValue-1', 'MyHeader: MyValue-2', 'MyHeader: MyValue-3'];
     $this->assertEquals($expectedHeaders, $response->renderHeaders());
 }