This commit is contained in:
2021-04-27 18:13:27 +08:00
parent 18913c0691
commit fe63bf4fdd
2 changed files with 4 additions and 11 deletions
-3
View File
@@ -51,9 +51,6 @@ class OnRequest extends Callback
public function onHandler(Request $request, Response $response): mixed public function onHandler(Request $request, Response $response): mixed
{ {
try { try {
$response->setStatusCode(200);
return $response->end('');
Coroutine::defer(function () { Coroutine::defer(function () {
fire(Event::SYSTEM_RESOURCE_RELEASES); fire(Event::SYSTEM_RESOURCE_RELEASES);
}); });
+4 -8
View File
@@ -152,18 +152,14 @@ class Response extends HttpService
/** /**
* @param string $context * @param string $context
* @param int $statusCode * @param int $statusCode
* @param null $appointResponse
* @return bool * @return bool
* @throws Exception * @throws Exception
*/ */
public function send($context = '', $statusCode = 200, $appointResponse = null): mixed public function send($context = '', $statusCode = 200): mixed
{ {
$sendData = $this->parseData($context); $sendData = $this->parseData($context);
$response = Context::getContext('response'); $response = Context::getContext('response');
if ($appointResponse instanceof SResponse) {
$response = $appointResponse;
}
if ($response instanceof SResponse) { if ($response instanceof SResponse) {
$this->sendData($response, $sendData, $statusCode); $this->sendData($response, $sendData, $statusCode);
} else { } else {
@@ -228,7 +224,7 @@ class Response extends HttpService
*/ */
private function sendData($response, $sendData, $status): void private function sendData($response, $sendData, $status): void
{ {
if (!swoole()->exist($response->fd)) { if (!Snowflake::getWebSocket()->exist($response->fd)) {
return; return;
} }
$response->end($this->setHeaders($response, $status) $response->end($this->setHeaders($response, $status)
@@ -243,8 +239,8 @@ class Response extends HttpService
*/ */
private function setResponseContent($sendData): string private function setResponseContent($sendData): string
{ {
$message = '[' . date('Y-m-d H:i:s') . ']' . $sendData . PHP_EOL . PHP_EOL; // $message = '[' . date('Y-m-d H:i:s') . ']' . $sendData . PHP_EOL . PHP_EOL;
Snowflake::writeFile(storage('response.log'), $message, FILE_APPEND); // Snowflake::writeFile(storage('response.log'), $message, FILE_APPEND);
return $sendData; return $sendData;
} }