From 3f03bb0e8b59a8c272b714020f6e41da4b18acf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 29 Sep 2021 16:04:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http-handler/Client/Client.php | 14 +++++++------- http-handler/Client/Curl.php | 8 +++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/http-handler/Client/Client.php b/http-handler/Client/Client.php index 83e1fbaa..cd0f2f01 100644 --- a/http-handler/Client/Client.php +++ b/http-handler/Client/Client.php @@ -98,16 +98,16 @@ class Client extends ClientAbstracts */ private function setParams(SwowClient $client, $path, $data): string { + $content = $this->getData()->getContents(); + if (!empty($content)) { + $client->setData($content); + } if ($this->isGet()) { if (!empty($data)) $path .= '?' . $data; - if (!empty($this->getData())) { - $client->setData($this->getData()); - } } else { - if (!empty($this->getData())) { - $client->setData($this->getData()); - } else { - $client->setData($this->mergeParams($data)); + $data = $this->mergeParams($data); + if (!empty($data)) { + $client->setData($data); } } return $path; diff --git a/http-handler/Client/Curl.php b/http-handler/Client/Curl.php index 9c1a0d4b..854fc227 100644 --- a/http-handler/Client/Curl.php +++ b/http-handler/Client/Curl.php @@ -55,12 +55,14 @@ class Curl extends ClientAbstracts if ($isHttps !== false) { $this->curlHandlerSslSet($resource); } - if (empty($params) && empty($this->getData())) { + + $contents = $this->getData()->getContents(); + if (empty($params) && empty($contents)) { return $resource; } - if (!empty($this->getData())) { - curl_setopt($resource, CURLOPT_POSTFIELDS, $this->getData()); + if (!empty($contents)) { + curl_setopt($resource, CURLOPT_POSTFIELDS, $contents); } else if ($method === self::POST) { curl_setopt($resource, CURLOPT_POSTFIELDS, $this->mergeParams($params)); } else if ($method === self::UPLOAD) {