From 3139e426d90dd0b463aaacf30625d71cbb87c0c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 14 Apr 2021 16:04:56 +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 | 4 ++-- HttpServer/Client/Curl.php | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/HttpServer/Client/ClientAbstracts.php b/HttpServer/Client/ClientAbstracts.php index ecf97e80..ae9c39eb 100644 --- a/HttpServer/Client/ClientAbstracts.php +++ b/HttpServer/Client/ClientAbstracts.php @@ -530,9 +530,9 @@ abstract class ClientAbstracts extends Component implements IClient /** * @param $newData - * @return mixed + * @return string */ - protected function mergeParams($newData): mixed + protected function mergeParams($newData): string { if (empty($this->getData())) { return $this->toRequest($newData); diff --git a/HttpServer/Client/Curl.php b/HttpServer/Client/Curl.php index c4bdd5a1..c47d1f0c 100644 --- a/HttpServer/Client/Curl.php +++ b/HttpServer/Client/Curl.php @@ -54,12 +54,11 @@ class Curl extends ClientAbstracts return $resource; } - if ($method === self::GET && !empty($this->getData())) { + if (!empty($this->getData())) { curl_setopt($resource, CURLOPT_POSTFIELDS, $this->getData()); } else if ($method === self::POST) { curl_setopt($resource, CURLOPT_POSTFIELDS, $this->mergeParams($params)); - } - if ($method === self::UPLOAD) { + } else if ($method === self::UPLOAD) { curl_setopt($resource, CURLOPT_POSTFIELDS, $params); } return $resource;