From 38124ccd12adf26f6a8874c21b9a32257fdc0bb4 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 23 Jun 2016 17:13:07 +0800 Subject: [PATCH] =?UTF-8?q?Request=E7=B1=BB=E6=B7=BB=E5=8A=A0getContent?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8Ccreate=E6=96=B9=E6=B3=95=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0content=E5=8F=82=E6=95=B0=E6=94=AF=E6=8C=81=E4=BC=AA?= =?UTF-8?q?=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Request.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/library/think/Request.php b/library/think/Request.php index f72d6bb5..8d4f6c78 100644 --- a/library/think/Request.php +++ b/library/think/Request.php @@ -109,6 +109,8 @@ class Request 'csv' => 'text/csv', ]; + protected $content; + // 全局过滤规则 protected $filter; // Hook扩展方法 @@ -178,9 +180,10 @@ class Request * @param array $cookie * @param array $files * @param array $server + * @param string $content * @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['REQUEST_METHOD'] = strtoupper($method); @@ -236,6 +239,7 @@ class Request $options['pathinfo'] = ltrim($info['path'], '/'); $options['method'] = $server['REQUEST_METHOD']; $options['domain'] = $server['HTTP_HOST']; + $options['content'] = $content; self::$instance = new self($options); 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; + } }