From 952014f157b36b2468436c14d3eb2a2f80bd33be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 25 Nov 2020 17:49:45 +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/Curl.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/HttpServer/Client/Curl.php b/HttpServer/Client/Curl.php index 2627a168..ee1699ee 100644 --- a/HttpServer/Client/Curl.php +++ b/HttpServer/Client/Curl.php @@ -41,6 +41,9 @@ class Curl extends ClientAbstracts [$host, $isHttps, $path] = $this->matchHost($path); $host = $isHttps ? 'https://' . $host : 'http://' . $host; + if ($this->getPort() != 443 && $this->getPort() != 80) { + $host .= ':' . $this->getPort(); + } $resource = $this->do(curl_init($host . $path), $host . $path, $method); if ($isHttps !== false) { @@ -49,8 +52,12 @@ class Curl extends ClientAbstracts if (empty($params)) { return $resource; } + + if ($method === self::GET && !empty($this->getData())) { + curl_setopt($resource, CURLOPT_POSTFIELDS, $this->getData()); + } if ($method === self::POST) { - curl_setopt($resource, CURLOPT_POSTFIELDS, HttpParse::parse($params)); + curl_setopt($resource, CURLOPT_POSTFIELDS, $this->mergeParams($params)); } if ($method === self::UPLOAD) { curl_setopt($resource, CURLOPT_POSTFIELDS, $params); @@ -91,6 +98,7 @@ class Curl extends ClientAbstracts */ private function do($resource, $path, $method) { + var_dump($path); curl_setopt($resource, CURLOPT_URL, $path); curl_setopt($resource, CURLOPT_TIMEOUT, $this->getTimeout()); // 超时设置 curl_setopt($resource, CURLOPT_CONNECTTIMEOUT, $this->getConnectTimeout()); // 超时设置