Esempio n. 1
0
 /**
  * @param Body $body
  */
 public static function sendRawBodyResponse(Body $body)
 {
     if (headers_sent() === false) {
         header_remove();
         $message = sprintf("HTTP/1.0 %d %s", $body->getStatusCode(), $body->getReasonPhrase());
         header($message, true, $body->getStatusCode());
     }
     $body->sendData();
     flush();
 }
Esempio n. 2
0
 /**
  * Gets the response reason phrase associated with the status code.
  *
  * Because a reason phrase is not a required element in a response
  * status line, the reason phrase value MAY be null. Implementations MAY
  * choose to return the default RFC 7231 recommended reason phrase (or those
  * listed in the IANA HTTP Status Code Registry) for the response's
  * status code.
  *
  * @link http://tools.ietf.org/html/rfc7231#section-6
  * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
  * @return string Reason phrase; must return an empty string if none present.
  */
 public function getReasonPhrase()
 {
     if ($this->overridingReasonPhrase !== '') {
         return $this->overridingReasonPhrase;
     }
     $bodyReasonPhrase = $this->body->getReasonPhrase();
     if ($bodyReasonPhrase !== null) {
         return $bodyReasonPhrase;
     }
     $statusCode = $this->getStatusCode();
     if (isset(self::$phrases[$statusCode]) === true) {
         return self::$phrases[$statusCode];
     }
     return "";
 }