This commit is contained in:
as2252258@163.com
2021-08-28 02:52:25 +08:00
parent 107d452fcf
commit 992bc2cc16
+7 -3
View File
@@ -73,10 +73,14 @@ class Http extends \Server\Abstracts\Http implements OnClose, OnConnect
}
}
if (is_array($responseData)) {
return $interface->withBody(new Stream(json_encode($responseData, JSON_UNESCAPED_UNICODE)))
->withContentType(\Server\Message\Response::CONTENT_TYPE_JSON);
$responseData = new Stream(json_encode($responseData, JSON_UNESCAPED_UNICODE));
} else {
$responseData = new Stream((string)$responseData);
}
return $interface->withBody(new Stream((string)$responseData));
if (!$interface->hasHeader('Content-Type')) {
$interface->withContentType(\Server\Message\Response::CONTENT_TYPE_JSON);
}
return $interface->withBody($responseData);
}