Ejemplo n.º 1
0
 public static function setResponseStatusCode($code, $sentHttpStatus = false, $checkIfHeaderSent = true, $httpProtocol = null)
 {
     if (!ResponseCode::isValid($code)) {
         throw new \Exception('Response Code parameter must be a valid http response code');
     }
     if (!is_bool($sentHttpStatus)) {
         throw new \Exception('withHttpStatus parameter must be an boolean');
     }
     http_response_code($code);
     if ($sentHttpStatus) {
         $httpProtocolVersion = !is_null($httpProtocol) && Protocol::isValid($httpProtocol) ? $httpProtocol : str_replace('HTTP/', '', Http::getServer('SERVER_PROTOCOL'));
         $statusMessage = ResponseCode::getMessage($code, false);
         self::sentHeader('HTTP', '/' . (string) $httpProtocolVersion . ' ' . $statusMessage, true, $code, $checkIfHeaderSent, null);
         self::sentHeader('Status', $statusMessage, true, $code, $checkIfHeaderSent);
     }
 }
Ejemplo n.º 2
0
 public function setHttpResponseStatusCode($httpResponseStatusCode)
 {
     if (!is_null($httpResponseStatusCode) && !ResponseCode::isValid($httpResponseStatusCode)) {
         throw new \Exception('Route httpResponseStatusCode parameter must null or a valid HTTP ResponseCode');
     }
     $this->_httpResponseStatusCode = $httpResponseStatusCode;
 }