This commit is contained in:
2020-11-18 17:00:16 +08:00
parent a47d1aaf06
commit 52093df208
4 changed files with 9 additions and 12 deletions
+1
View File
@@ -10,6 +10,7 @@ declare(strict_types=1);
namespace HttpServer\Client;
use Exception;
use Swoole\Coroutine;
use Swoole\Coroutine\Http\Client as SClient;
/**
+4 -9
View File
@@ -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;
+1 -2
View File
@@ -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);
}
}
+3 -1
View File
@@ -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;