fix(JsonResponse): better protocol header
This commit is contained in:
parent
e4cdba842c
commit
b3c88781d7
@ -128,7 +128,7 @@ class JsonResponse implements JsonSerializable
|
||||
public function sendHeaders(): JsonResponse
|
||||
{
|
||||
// headers have already been sent by the developer
|
||||
if (!headers_sent()) {
|
||||
if (!headers_sent() && !in_array(php_sapi_name(), ['cli', 'cli-server',' phpdbg'], true)) {
|
||||
|
||||
// headers
|
||||
foreach ($this->headers as $name => $value) {
|
||||
@ -137,7 +137,8 @@ class JsonResponse implements JsonSerializable
|
||||
|
||||
// status
|
||||
$statusText = self::HTTP_CODES[$this->code];
|
||||
header("HTTP/1.0 {$this->code} $statusText");
|
||||
$protocol = !empty($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
|
||||
header("$protocol {$this->code} $statusText");
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
Loading…
x
Reference in New Issue
Block a user