diff --git a/HttpServer/Client/Client.php b/HttpServer/Client/Client.php index dad08498..0500ed94 100644 --- a/HttpServer/Client/Client.php +++ b/HttpServer/Client/Client.php @@ -10,6 +10,7 @@ declare(strict_types=1); namespace HttpServer\Client; use Exception; +use Swoole\Coroutine; use Swoole\Coroutine\Http\Client as SClient; /** diff --git a/HttpServer/Client/ClientAbstracts.php b/HttpServer/Client/ClientAbstracts.php index c9a6de56..d75c887a 100644 --- a/HttpServer/Client/ClientAbstracts.php +++ b/HttpServer/Client/ClientAbstracts.php @@ -733,19 +733,14 @@ abstract class ClientAbstracts extends Component implements IClient if (strpos($domain, ':' . $port) !== false) { $domain = str_replace(':' . $port, '', $domain); } + $this->port = $isHttps ? 443 : $this->port; if (isIp($domain)) { $this->host = $domain; - } else { + } else if ($this->isUseSwoole()) { $this->host = System::gethostbyname($domain) ?? $domain; + } else { + $this->host = $domain; } - - if (!empty($this->port)) { - $port = $this->port; - } - if (!empty($port) && $port != 443) { - $this->host .= ':' . $port; - } - $this->header['Host'] = $domain; if (strpos($path, '/') !== 0) { $path = '/' . $path; diff --git a/HttpServer/Client/Curl.php b/HttpServer/Client/Curl.php index 2d1228c3..2627a168 100644 --- a/HttpServer/Client/Curl.php +++ b/HttpServer/Client/Curl.php @@ -114,7 +114,7 @@ class Curl extends ClientAbstracts if ($method === self::POST || $method == self::UPLOAD) { curl_setopt($resource, CURLOPT_POST, 1); } - curl_setopt($resource, CURLOPT_CUSTOMREQUEST, $method); + curl_setopt($resource, CURLOPT_CUSTOMREQUEST, strtoupper($method)); return $resource; } @@ -207,7 +207,6 @@ class Curl extends ClientAbstracts foreach ($this->getHeader() as $key => $val) { $headers[$key] = $key . ': ' . $val; } - var_dump($headers); return array_values($headers); } } diff --git a/HttpServer/Client/Result.php b/HttpServer/Client/Result.php index 2d017655..1e3b6109 100644 --- a/HttpServer/Client/Result.php +++ b/HttpServer/Client/Result.php @@ -20,7 +20,9 @@ class Result public $code; public $message; public int $count = 0; - public ?array $data; + + /** @var mixed $data */ + public $data; public ?array $header; public int $httpStatus = 200;