From 8a5f4ff4022c3b868f1e307156b8c7495d2dc976 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 20 Jul 2016 14:31:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BRequest=E7=B1=BB=E6=94=AF?= =?UTF-8?q?=E6=8C=81PATCH=E8=AF=B7=E6=B1=82=E5=8F=98=E9=87=8F=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=20=E6=94=B9=E8=BF=9B=E8=AF=B7=E6=B1=82=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E4=BC=AA=E9=80=A0=E5=90=8E=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Request.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/library/think/Request.php b/library/think/Request.php index 798575d9..c19cd9ee 100644 --- a/library/think/Request.php +++ b/library/think/Request.php @@ -83,7 +83,6 @@ class Request protected $request = []; protected $route = []; protected $put; - protected $delete; protected $session = []; protected $file = []; protected $cookie = []; @@ -490,6 +489,7 @@ class Request } elseif (!$this->method) { if (isset($_POST[Config::get('var_method')])) { $this->method = strtoupper($_POST[Config::get('var_method')]); + $this->{$this->method}($_POST); } elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) { $this->method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']); } else { @@ -612,10 +612,9 @@ class Request $vars = $this->post(false); break; case 'PUT': - $vars = $this->put(false); - break; case 'DELETE': - $vars = $this->delete(false); + case 'PATCH': + $vars = $this->put(false); break; default: $vars = []; @@ -718,13 +717,20 @@ class Request */ public function delete($name = '', $default = null, $filter = null) { - if (is_array($name)) { - return $this->delete = is_null($this->delete) ? $name : array_merge($this->delete, $name); - } - if (is_null($this->delete)) { - parse_str(file_get_contents('php://input'), $this->delete); - } - return $this->input($this->delete, $name, $default, $filter); + return $this->put($name, $default, $filter); + } + + /** + * 设置获取获取PATCH参数 + * @access public + * @param string|array $name 变量名 + * @param mixed $default 默认值 + * @param string|array $filter 过滤方法 + * @return mixed + */ + public function patch($name = '', $default = null, $filter = null) + { + return $this->put($name, $default, $filter); } /**