mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
优化方法检测判断
This commit is contained in:
@@ -521,19 +521,24 @@ class Request
|
|||||||
// 获取原始请求类型
|
// 获取原始请求类型
|
||||||
return $this->server('REQUEST_METHOD') ?: 'GET';
|
return $this->server('REQUEST_METHOD') ?: 'GET';
|
||||||
} elseif (!$this->method) {
|
} elseif (!$this->method) {
|
||||||
if (isset($_POST[Config::get('var_method')])) {
|
$varMethod = Config::get('var_method');
|
||||||
$method = strtoupper($_POST[Config::get('var_method')]);
|
if ($varMethod && isset($_POST[$varMethod])) {
|
||||||
|
$method = strtoupper($_POST[$varMethod]);
|
||||||
if (in_array($method, ['GET', 'POST', 'DELETE', 'PUT', 'PATCH'])) {
|
if (in_array($method, ['GET', 'POST', 'DELETE', 'PUT', 'PATCH'])) {
|
||||||
$this->method = $method;
|
$this->method = $method;
|
||||||
$this->{$this->method}($_POST);
|
$this->{$this->method}($_POST);
|
||||||
} else {
|
} else {
|
||||||
$this->method = 'POST';
|
$this->method = 'POST';
|
||||||
}
|
}
|
||||||
unset($_POST[Config::get('var_method')]);
|
unset($_POST[$varMethod]);
|
||||||
} elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
|
|
||||||
$this->method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
|
|
||||||
} else {
|
} else {
|
||||||
$this->method = $this->server('REQUEST_METHOD') ?: 'GET';
|
$method = $this->server('REQUEST_METHOD') ?: 'GET';
|
||||||
|
$httpMethodOverride = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ?? '');
|
||||||
|
if ($method === 'POST' && in_array($httpMethodOverride, ['GET', 'POST', 'DELETE', 'PUT', 'PATCH'])) {
|
||||||
|
$this->method = $httpMethodOverride;
|
||||||
|
} else {
|
||||||
|
$this->method = $method;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->method;
|
return $this->method;
|
||||||
|
|||||||
Reference in New Issue
Block a user