mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
Request类添加getContent方法,create方法增加content参数支持伪造
This commit is contained in:
@@ -109,6 +109,8 @@ class Request
|
|||||||
'csv' => 'text/csv',
|
'csv' => 'text/csv',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $content;
|
||||||
|
|
||||||
// 全局过滤规则
|
// 全局过滤规则
|
||||||
protected $filter;
|
protected $filter;
|
||||||
// Hook扩展方法
|
// Hook扩展方法
|
||||||
@@ -178,9 +180,10 @@ class Request
|
|||||||
* @param array $cookie
|
* @param array $cookie
|
||||||
* @param array $files
|
* @param array $files
|
||||||
* @param array $server
|
* @param array $server
|
||||||
|
* @param string $content
|
||||||
* @return \think\Request
|
* @return \think\Request
|
||||||
*/
|
*/
|
||||||
public static function create($uri, $method = 'GET', $params = [], $cookie = [], $files = [], $server = [])
|
public static function create($uri, $method = 'GET', $params = [], $cookie = [], $files = [], $server = [], $content = null)
|
||||||
{
|
{
|
||||||
$server['PATH_INFO'] = '';
|
$server['PATH_INFO'] = '';
|
||||||
$server['REQUEST_METHOD'] = strtoupper($method);
|
$server['REQUEST_METHOD'] = strtoupper($method);
|
||||||
@@ -236,6 +239,7 @@ class Request
|
|||||||
$options['pathinfo'] = ltrim($info['path'], '/');
|
$options['pathinfo'] = ltrim($info['path'], '/');
|
||||||
$options['method'] = $server['REQUEST_METHOD'];
|
$options['method'] = $server['REQUEST_METHOD'];
|
||||||
$options['domain'] = $server['HTTP_HOST'];
|
$options['domain'] = $server['HTTP_HOST'];
|
||||||
|
$options['content'] = $content;
|
||||||
self::$instance = new self($options);
|
self::$instance = new self($options);
|
||||||
return self::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
@@ -1367,4 +1371,16 @@ class Request
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置或者获取当前请求的content
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getContent()
|
||||||
|
{
|
||||||
|
if (null === $this->content) {
|
||||||
|
$this->content = file_get_contents('php://input');
|
||||||
|
}
|
||||||
|
return $this->content;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user