modify
This commit is contained in:
@@ -525,7 +525,7 @@ class Router extends HttpService implements RouterInterface
|
||||
$node = $this->find_path(\request());
|
||||
if (!($node instanceof Node)) {
|
||||
$this->response->setFormat(Response::HTML);
|
||||
$this->response->send('<h1>404</h1>');
|
||||
$this->response->send('<h1 style="text-align: center;">404</h1>');
|
||||
} else {
|
||||
$this->response->send(($response = $node->dispatch()), 200);
|
||||
if ($node->hasAfter()) {
|
||||
@@ -535,6 +535,13 @@ class Router extends HttpService implements RouterInterface
|
||||
}
|
||||
|
||||
|
||||
public function status404()
|
||||
{
|
||||
$this->response->setFormat(Response::HTML);
|
||||
$this->response->send('<h1 style="text-align: center;">404</h1>');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $exception
|
||||
* @return mixed
|
||||
|
||||
@@ -106,16 +106,11 @@ class HTTPServerListener extends Abstracts\Server
|
||||
public function onRequest(Request $request, Response $response)
|
||||
{
|
||||
try {
|
||||
if (ApplicationStore::getStore()->getStatus() == 'exit') {
|
||||
$response->status(401);
|
||||
$response->end();
|
||||
return;
|
||||
}
|
||||
$request = HRequest::create($request, $response);
|
||||
if ($request->is('favicon.ico')) {
|
||||
throw new Exception('Not found.', 404);
|
||||
}
|
||||
if (HRequest::create($request, $response)->is('favicon.ico')) {
|
||||
$this->router->status404();
|
||||
} else {
|
||||
$this->router->dispatch();
|
||||
}
|
||||
} catch (ExitException | Error | Throwable $exception) {
|
||||
$response->setHeader('Content-Type', 'text/html; charset=utf-8');
|
||||
$response->status($exception->getCode() == 0 ? 500 : $exception->getCode());
|
||||
|
||||
Reference in New Issue
Block a user