This commit is contained in:
2021-03-30 19:30:10 +08:00
parent 942b0cec0f
commit c85099b1b1
2 changed files with 14 additions and 2 deletions
+2 -1
View File
@@ -9,6 +9,7 @@ use Exception;
use HttpServer\Abstracts\Callback; use HttpServer\Abstracts\Callback;
use HttpServer\Http\HttpParams; use HttpServer\Http\HttpParams;
use HttpServer\Http\Request; use HttpServer\Http\Request;
use HttpServer\Http\Response;
use Snowflake\Event; use Snowflake\Event;
use Snowflake\Snowflake; use Snowflake\Snowflake;
use Swoole\Http\Request as SRequest; use Swoole\Http\Request as SRequest;
@@ -133,7 +134,7 @@ class OnHandshake extends Callback
if (($node = $router->find_path($sRequest)) === null) { if (($node = $router->find_path($sRequest)) === null) {
return $this->disconnect($response, 502); return $this->disconnect($response, 502);
} }
return $node->dispatch($request, $response); return $node->dispatch($sRequest, Response::create($response));
} }
+12 -1
View File
@@ -283,6 +283,18 @@ class Response extends HttpService
} }
/**
* @param int $statusCode
* @param string $message
* @return mixed
* @throws Exception
*/
public function close($statusCode = 200, $message = ''): mixed
{
return $this->send($message, $statusCode);
}
/** /**
* @param string $path * @param string $path
* @param int $offset * @param int $offset
@@ -296,7 +308,6 @@ class Response extends HttpService
$stat = fstat($open); $stat = fstat($open);
$this->headers(null);
while ($file = fread($open, $limit)) { while ($file = fread($open, $limit)) {
$this->response->write($file); $this->response->write($file);
fseek($open, $offset); fseek($open, $offset);