add clear

This commit is contained in:
2020-04-03 18:31:29 +08:00
parent f8103f93b9
commit a67ecd7493
+16 -6
View File
@@ -283,9 +283,6 @@ class HttpClient
$data = $this->paramEncode($data);
if ($this->use_swoole) {
$url = $this->matchHost($url);
if (!$this->checkIsIp($this->host)) {
$this->host = System::gethostbyname($this->host);
}
return $this->coroutine($this->host, $url, $data);
} else {
return $this->useCurl($url, $data);
@@ -309,18 +306,27 @@ class HttpClient
if (empty($string)) {
return false;
}
$string = str_replace('http://', '', $string);
// 手动设置请求域名
if (!empty($this->host)) {
if (!$this->checkIsIp($this->host)) {
$this->host = System::gethostbyname($this->host);
}
return $string;
}
// 替换请求头为空
$string = str_replace('http://', '', $string);
if ($this->isHttps($string)) {
$string = str_replace('https://', '', $string);
$this->isSSL = true;
$this->port = 443;
$this->setIsSSL(true);
}
$hostAndUrls = explode('/', $string);
if (empty($hostAndUrls)) {
return false;
}
$this->host = array_shift($hostAndUrls);
$hostAndUrls = implode('/', $hostAndUrls);
if (strpos($this->host, ':') !== false) {
@@ -329,9 +335,13 @@ class HttpClient
return '/' . $hostAndUrls;
}
}
if (!$this->isDomainName($this->host)) {
return false;
}
$this->host = System::gethostbyname($this->host);
return '/' . $hostAndUrls;
}