提交 a521d94d 编写于 作者: lzc828's avatar lzc828

处理页面关闭后 后台还在执行输出的警告

上级 47aa884b
......@@ -2,7 +2,6 @@
namespace One\Http;
use App\Protocol\AppHttpServer;
use One\Exceptions\HttpException;
use One\Facades\Log;
......@@ -20,7 +19,7 @@ class Controller
protected $response = null;
/**
* @var AppHttpServer
* @var \App\Server\AppHttpServer
*/
protected $server;
......@@ -107,10 +106,10 @@ class Controller
final protected function display($tpl, $data = [])
{
$dir = substr(get_called_class(), 4);
$dir = str_replace(['Controllers','Controller'],'',$dir);
$dir = str_replace('\\','/',$dir);
$dir = str_replace('//','/',$dir);
$dir = strtolower(trim($dir,'/'));
$dir = str_replace(['Controllers', 'Controller'], '', $dir);
$dir = str_replace('\\', '/', $dir);
$dir = str_replace('//', '/', $dir);
$dir = strtolower(trim($dir, '/'));
return $this->response->tpl($dir . '/' . $tpl, $data);
}
......
......@@ -17,6 +17,8 @@ class Request
protected $request = [];
public $fd = 0;
public $args = [];
public $class = '';
......
......@@ -42,7 +42,8 @@ trait HttpEvent
} catch (\Throwable $e) {
$data = $e->getMessage();
}
if ($data) {
$response->exist = $this->server->exist($request->fd);
if ($data && $response->exist) {
$response->write($data);
}
......
......@@ -35,7 +35,7 @@ class Port
public function __construct($server, $conf)
{
$this->server = $server;
$this->conf = $conf;
$this->conf = $conf;
if (isset($conf['protocol'])) {
$this->protocol = $conf['protocol'];
}
......
......@@ -21,6 +21,7 @@ class Request extends \One\Http\Request
foreach ($request->header as $k => $v){
$this->server['HTTP_'.str_replace('-','_',strtoupper($k))] = $v;
}
$this->fd = $request->fd;
$this->cookie = &$request->cookie;
$this->get = &$request->get;
$this->post = &$request->post;
......
......@@ -60,7 +60,9 @@ class Response extends \One\Http\Response
public function __destruct()
{
$this->httpResponse->end();
if ($this->httpResponse->exist) {
$this->httpResponse->end();
}
}
}
\ No newline at end of file
......@@ -40,7 +40,7 @@ class Server
public function __construct(\swoole_server $server, array $conf)
{
$this->server = $server;
$this->conf = $conf;
$this->conf = $conf;
if (isset($conf['protocol'])) {
$this->protocol = $conf['protocol'];
}
......@@ -68,8 +68,8 @@ class Server
public function onWorkerStart(\swoole_server $server, $worker_id)
{
$this->worker_id = $worker_id;
$this->is_task = $server->taskworker ? true : false;
$this->pid = $server->worker_pid;
$this->is_task = $server->taskworker ? true : false;
$this->pid = $server->worker_pid;
if (isset($this->conf['global_data'])) {
$this->globalData = $this->globalData($this->conf['global_data']);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册