From 583630d0ca1ad421c235aa7b14eed0b858f0c801 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Tue, 7 Jan 2020 14:46:50 +0800 Subject: [PATCH] add clear --- common/HttpClient.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/HttpClient.php b/common/HttpClient.php index 6ba2eea..15043fc 100644 --- a/common/HttpClient.php +++ b/common/HttpClient.php @@ -125,7 +125,11 @@ class HttpClient */ 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)) { return $host; } - $this->addHeader('Host', $host); return System::gethostbyname($host); }