This commit is contained in:
2021-04-14 16:04:17 +08:00
parent d51a912ddf
commit 8c336e7cd5
2 changed files with 4 additions and 4 deletions
+2 -1
View File
@@ -7,6 +7,7 @@ namespace HttpServer\Client;
use Closure; use Closure;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure;
use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Component;
use Snowflake\Core\Help; use Snowflake\Core\Help;
use Snowflake\Core\Json; use Snowflake\Core\Json;
@@ -58,7 +59,7 @@ abstract class ClientAbstracts extends Component implements IClient
/** /**
* @return static * @return static
*/ */
public static function NewRequest(): static #[Pure] public static function NewRequest(): static
{ {
return new static(); return new static();
} }
+2 -3
View File
@@ -50,14 +50,13 @@ class Curl extends ClientAbstracts
if ($isHttps !== false) { if ($isHttps !== false) {
$this->curlHandlerSslSet($resource); $this->curlHandlerSslSet($resource);
} }
if (empty($params)) { if (empty($params) && empty($this->getData())) {
return $resource; return $resource;
} }
if ($method === self::GET && !empty($this->getData())) { if ($method === self::GET && !empty($this->getData())) {
curl_setopt($resource, CURLOPT_POSTFIELDS, $this->getData()); curl_setopt($resource, CURLOPT_POSTFIELDS, $this->getData());
} } else if ($method === self::POST) {
if ($method === self::POST) {
curl_setopt($resource, CURLOPT_POSTFIELDS, $this->mergeParams($params)); curl_setopt($resource, CURLOPT_POSTFIELDS, $this->mergeParams($params));
} }
if ($method === self::UPLOAD) { if ($method === self::UPLOAD) {