Exemplo n.º 1
0
 public function respond()
 {
     if (!headers_sent()) {
         // Status
         header(sprintf('HTTP/%s %s %s', $this->response->getProtocolVersion(), $this->response->getStatusCode(), $this->response->getReasonPhrase()));
         // Headers
         foreach ($this->response->getHeaders() as $name => $value) {
             header(sprintf('%s: %s', $name, $value), false);
         }
     }
     $body = $this->response->getBody();
     if ($body) {
         echo $body;
     }
     return $this;
 }
Exemplo n.º 2
0
 private static function responseToString(Response $response)
 {
     $headers = $response->getHeaders();
     $headerList = [];
     foreach ($headers as $key => $value) {
         $headerList[] = $key . ': ' . $value;
     }
     $headerStr = implode('|', $headerList);
     $list = [$response->getStatusCode(), $headerStr, $response->getBody()];
     return implode(' `` ', $list);
 }