add clear

This commit is contained in:
as2252258@163.com
2020-01-07 14:46:50 +08:00
parent ea6c53796a
commit 583630d0ca
+5 -2
View File
@@ -125,7 +125,11 @@ class HttpClient
*/ */
public function setHost(string $host) public function setHost(string $host)
{ {
$this->host = $host; $this->host = $this->replaceHost($host);
$match_quest = '/^[a-zA-Z\-](\.[a-zA-Z\-])*/';
if (preg_match($match_quest, $this->host)) {
$this->addHeader('Host', $this->host);
}
} }
/** /**
@@ -262,7 +266,6 @@ class HttpClient
if ($this->checkIsIp($host)) { if ($this->checkIsIp($host)) {
return $host; return $host;
} }
$this->addHeader('Host', $host);
return System::gethostbyname($host); return System::gethostbyname($host);
} }