From fc5820cf7fc85bd1578318df176e2d0fc2e2430d Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 27 Jul 2016 18:10:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Babort=E5=8A=A9=E6=89=8B?= =?UTF-8?q?=E5=87=BD=E6=95=B0=20=E6=94=AF=E6=8C=81=E6=8A=9B=E5=87=BAHttpRe?= =?UTF-8?q?sponseException=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/helper.php b/helper.php index 57b8ae49..6896b655 100644 --- a/helper.php +++ b/helper.php @@ -497,12 +497,16 @@ if (!function_exists('redirect')) { if (!function_exists('abort')) { /** * 抛出HTTP异常 - * @param integer $code 状态码 - * @param string $message 错误信息 - * @param array $header 参数 + * @param integer|Response $code 状态码 或者 Response对象实例 + * @param string $message 错误信息 + * @param array $header 参数 */ function abort($code, $message = null, $header = []) { - throw new \think\exception\HttpException($code, $message, null, $header); + if ($code instanceof Response) { + throw new \think\exception\HttpResponseException($code); + } else { + throw new \think\exception\HttpException($code, $message, null, $header); + } } }