Пример #1
0
 /**
  * Sets the http response status code
  *
  * @param int $code The status code to set
  *
  * @return void
  */
 public function setStatusCode($code)
 {
     // set status code
     $this->statusCode = $code;
     // lookup reason phrase by code and set
     $this->setStatusReasonPhrase(HttpProtocol::getStatusReasonPhraseByCode($code));
 }
Пример #2
0
 /**
  * Sets the http response status code
  *
  * @param int $code The status code to set
  *
  * @return void
  */
 public function setStatusCode($code)
 {
     // set status code
     $this->statusCode = $code;
     // we have to react on certain status codes in a certain way, do that here
     // We have to discard the body on status codes 1xx, 204 and 304.
     // @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3
     // @see https://tools.ietf.org/html/rfc2068#section-14.14
     $statusCode = (int) $this->getStatusCode();
     if ($statusCode === 304 || $statusCode === 204 || $statusCode >= 100 && $statusCode < 200) {
         $this->resetBodyStream();
         // set the content length accordingly
         $this->addHeader(HttpProtocol::HEADER_CONTENT_LENGTH, 0);
     }
     // lookup reason phrase by code and set
     $this->setStatusReasonPhrase(HttpProtocol::getStatusReasonPhraseByCode($code));
 }