Exemplo n.º 1
0
 /**
  * @param \PSX\Http\ResponseInterface $response
  * @return string
  */
 public static function buildStatusLine(ResponseInterface $response)
 {
     $protocol = $response->getProtocolVersion();
     $code = $response->getStatusCode();
     $phrase = $response->getReasonPhrase();
     if (empty($code)) {
         throw new Exception('Status code not set');
     }
     $protocol = !empty($protocol) ? $protocol : 'HTTP/1.1';
     if (empty($phrase) && isset(Http::$codes[$code])) {
         $phrase = Http::$codes[$code];
     }
     if (empty($phrase)) {
         throw new Exception('No reason phrase provided');
     }
     return $protocol . ' ' . $code . ' ' . $phrase;
 }
Exemplo n.º 2
0
Arquivo: Basic.php Projeto: seytar/psx
 protected function sendStatusLine(ResponseInterface $response)
 {
     $scheme = $response->getProtocolVersion();
     if (empty($scheme)) {
         $scheme = 'HTTP/1.1';
     }
     $code = $response->getStatusCode();
     if (!isset(Http::$codes[$code])) {
         $code = 200;
     }
     $this->sendHeader($scheme . ' ' . $code . ' ' . Http::$codes[$code]);
 }