This commit is contained in:
2021-08-01 16:05:55 +08:00
parent c33a5af377
commit 3d190ae839
+4 -6
View File
@@ -165,7 +165,7 @@ class Response extends HttpService
{ {
$sendData = $this->parseData($context); $sendData = $this->parseData($context);
$this->statusCode = $statusCode; $this->statusCode = $statusCode;
if (!Context::hasContext('response')) { if (!Context::hasContext(SResponse::class)) {
$this->printResult($sendData); $this->printResult($sendData);
} else { } else {
$this->sendData($sendData); $this->sendData($sendData);
@@ -217,8 +217,8 @@ class Response extends HttpService
*/ */
private function sendData($sendData): void private function sendData($sendData): void
{ {
$response = Context::getContext('response'); $response = Context::getContext(SResponse::class);
if (!$response || !$response->isWritable()) { if (!$response?->isWritable()) {
return; return;
} }
$this->setCookies($response); $this->setCookies($response);
@@ -270,13 +270,11 @@ class Response extends HttpService
/** /**
* @param null $response
* @return static * @return static
* @throws Exception * @throws Exception
*/ */
public static function create($response = null): static public static function create(): static
{ {
Context::setContext('response', $response);
$ciResponse = Snowflake::app()->get('response'); $ciResponse = Snowflake::app()->get('response');
$ciResponse->startTime = microtime(true); $ciResponse->startTime = microtime(true);
$ciResponse->format = self::JSON; $ciResponse->format = self::JSON;