From 8c336e7cd5aef58ff09f65ad2748c5a854548132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 14 Apr 2021 16:04:17 +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 --- HttpServer/Client/ClientAbstracts.php | 3 ++- HttpServer/Client/Curl.php | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/HttpServer/Client/ClientAbstracts.php b/HttpServer/Client/ClientAbstracts.php index 4848550c..ecf97e80 100644 --- a/HttpServer/Client/ClientAbstracts.php +++ b/HttpServer/Client/ClientAbstracts.php @@ -7,6 +7,7 @@ namespace HttpServer\Client; use Closure; use Exception; +use JetBrains\PhpStorm\Pure; use Snowflake\Abstracts\Component; use Snowflake\Core\Help; use Snowflake\Core\Json; @@ -58,7 +59,7 @@ abstract class ClientAbstracts extends Component implements IClient /** * @return static */ - public static function NewRequest(): static + #[Pure] public static function NewRequest(): static { return new static(); } diff --git a/HttpServer/Client/Curl.php b/HttpServer/Client/Curl.php index a1cf7dfe..c4bdd5a1 100644 --- a/HttpServer/Client/Curl.php +++ b/HttpServer/Client/Curl.php @@ -50,14 +50,13 @@ class Curl extends ClientAbstracts if ($isHttps !== false) { $this->curlHandlerSslSet($resource); } - if (empty($params)) { + if (empty($params) && empty($this->getData())) { return $resource; } if ($method === self::GET && !empty($this->getData())) { curl_setopt($resource, CURLOPT_POSTFIELDS, $this->getData()); - } - if ($method === self::POST) { + } else if ($method === self::POST) { curl_setopt($resource, CURLOPT_POSTFIELDS, $this->mergeParams($params)); } if ($method === self::UPLOAD) {