This commit is contained in:
2021-04-25 18:08:32 +08:00
parent 1ccaf39705
commit 70565b9c40
+10
View File
@@ -16,6 +16,7 @@ use HttpServer\Http\Formatter\JsonFormatter;
use HttpServer\Http\Formatter\XmlFormatter;
use JetBrains\PhpStorm\Pure;
use Snowflake\Core\Help;
use Snowflake\Core\Json;
use Snowflake\Snowflake;
use Swoole\Http\Response as SResponse;
use Swoole\Http2\Response as S2Response;
@@ -217,6 +218,7 @@ class Response extends HttpService
}
/**
* @param $response
* @param $sendData
* @param $status
* @throws Exception
@@ -226,11 +228,19 @@ class Response extends HttpService
if (!swoole()->exist($response->fd)) {
return;
}
if (is_array($sendData)) {
$sendData = Json::encode($sendData);
}
$response->end($this->setHeaders($response, $status)
->setResponseContent($sendData));
}
/**
* @param $sendData
* @return string
* @throws Exception
*/
private function setResponseContent($sendData): string
{
$message = '[' . date('Y-m-d H:i:s') . ']' . $sendData . PHP_EOL . PHP_EOL;