From 0962b21232eaea04350dd8705150128c1f1c5f47 Mon Sep 17 00:00:00 2001 From: quzhe Date: Tue, 29 Nov 2016 11:40:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A9Request=E6=94=AF=E6=8C=81json=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E7=9A=84POST=20=E7=9B=AE=E5=89=8DRESTful=20API?= =?UTF-8?q?=E7=94=A8json=E6=96=B9=E5=BC=8F=E6=8F=90=E4=BA=A4=E7=9A=84?= =?UTF-8?q?=E5=BE=88=E5=A4=9A=20=E7=9B=AE=E5=89=8DPUT/PATCH/DELETE?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=9D=87=E5=8F=AF=E4=BB=A5=E6=94=AF=E6=8C=81?= =?UTF-8?q?json=EF=BC=8C=E4=BD=86POST=E6=96=B9=E6=B3=95=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E8=BF=99=E4=B8=8D=E5=AF=B9=E7=AD=89=20=E5=85=B6?= =?UTF-8?q?=E5=AE=9E=E6=9B=B4=E5=A5=BD=E7=9A=84=E6=96=B9=E6=B3=95=E6=98=AF?= =?UTF-8?q?=E5=88=A4=E6=96=ADheader=E9=87=8Ccontent-type=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E4=B8=BAapplication/json=EF=BC=8C=E4=BD=86=E5=9B=A0=E4=B8=BA?= =?UTF-8?q?=E7=9B=AE=E5=89=8Dheader=E5=B1=9E=E6=80=A7=E9=87=87=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E6=98=AF=E6=87=92=E5=8A=A0=E8=BD=BD=EF=BC=8C=E6=89=80?= =?UTF-8?q?=E4=BB=A5=E6=9A=82=E6=97=B6=E6=B2=BF=E7=94=A8=E7=9B=AE=E5=89=8D?= =?UTF-8?q?=E7=9A=84=E5=AD=97=E7=AC=A6=E4=B8=B2=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Request.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/think/Request.php b/library/think/Request.php index d77e4e77..79c349f8 100644 --- a/library/think/Request.php +++ b/library/think/Request.php @@ -686,7 +686,12 @@ class Request public function post($name = '', $default = null, $filter = '') { if (empty($this->post)) { - $this->post = $_POST; + $content = $this->input; + if (empty($_POST) && strpos($content, '":')) { + $this->post = json_decode($content, true); + } else { + $this->post = $_POST; + } } if (is_array($name)) { $this->param = [];