优化Response类的send方法 改进app_end的监听位置

This commit is contained in:
thinkphp
2016-05-17 12:11:45 +08:00
parent cbc0597470
commit 9d5728c67f
2 changed files with 8 additions and 3 deletions

View File

@@ -109,13 +109,14 @@ class App
} catch (HttpResponseException $exception) {
$data = $exception->getResponse();
}
// 输出数据到客户端
// 监听app_end
APP_HOOK && Hook::listen('app_end', isset($data) ? $data : '');
if (isset($data)) {
// 输出数据到客户端
if ($data instanceof Response) {
return $data->send();
} else {
// 监听app_end
APP_HOOK && Hook::listen('app_end', $data);
$type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type');
return Response::create($data, $type)->send();
}

View File

@@ -111,6 +111,10 @@ class Response
}
}
echo $data;
if (function_exists('fastcgi_finish_request')) {
// 提高页面响应
fastcgi_finish_request();
}
return $data;
}