modify
This commit is contained in:
@@ -161,7 +161,7 @@ class Response extends HttpService
|
||||
$this->response = $response;
|
||||
}
|
||||
if ($this->response instanceof SResponse) {
|
||||
$this->sendData($sendData, $statusCode);
|
||||
$this->sendData($this->response, $sendData, $statusCode);
|
||||
} else {
|
||||
if (!empty(request()->fd)) {
|
||||
return '';
|
||||
@@ -221,37 +221,36 @@ class Response extends HttpService
|
||||
* @param $status
|
||||
* @throws Exception
|
||||
*/
|
||||
private function sendData($sendData, $status): void
|
||||
private function sendData($response, $sendData, $status): void
|
||||
{
|
||||
if (!$this->response->isWritable()) {
|
||||
if (!swoole()->exist($response->fd) || !$response->isWritable()) {
|
||||
return;
|
||||
}
|
||||
$this->setHeaders($status);
|
||||
$this->setHeaders($response, $status);
|
||||
if (empty($sendData)) {
|
||||
$this->response->end('');
|
||||
$response->end('');
|
||||
} else {
|
||||
$message = '[' . date('Y-m-d H:i:s') . ']' . $sendData . PHP_EOL . PHP_EOL;
|
||||
Snowflake::writeFile(storage('response.log'), $message, FILE_APPEND);
|
||||
$this->response->end($sendData);
|
||||
$response->end($sendData);
|
||||
}
|
||||
$this->response = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $status
|
||||
*/
|
||||
private function setHeaders($status): void
|
||||
private function setHeaders($response, $status): void
|
||||
{
|
||||
$this->response->status($status);
|
||||
$this->response->header('Content-Type', $this->getContentType());
|
||||
$this->response->header('Run-Time', $this->getRuntime());
|
||||
$response->status($status);
|
||||
$response->header('Content-Type', $this->getContentType());
|
||||
$response->header('Run-Time', $this->getRuntime());
|
||||
|
||||
if (empty($this->headers) || !is_array($this->headers)) {
|
||||
return;
|
||||
}
|
||||
foreach ($this->headers as $key => $header) {
|
||||
$this->response->header($key, $header, true);
|
||||
$response->header($key, $header, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user