fix(JsonResponse): better protocol header
This commit is contained in:
parent
e4cdba842c
commit
b3c88781d7
@ -125,10 +125,10 @@ class JsonResponse implements JsonSerializable
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function sendHeaders(): JsonResponse
|
public function sendHeaders(): JsonResponse
|
||||||
{
|
{
|
||||||
// headers have already been sent by the developer
|
// 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
|
// headers
|
||||||
foreach ($this->headers as $name => $value) {
|
foreach ($this->headers as $name => $value) {
|
||||||
@ -137,7 +137,8 @@ class JsonResponse implements JsonSerializable
|
|||||||
|
|
||||||
// status
|
// status
|
||||||
$statusText = self::HTTP_CODES[$this->code];
|
$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;
|
return $this;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user