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); } /**