add clear

This commit is contained in:
2021-04-06 15:49:46 +08:00
parent 74960d1df1
commit 50773cefad
+9 -7
View File
@@ -332,31 +332,31 @@ class HttpClient
* @return bool|string * @return bool|string
* @throws Exception * @throws Exception
*/ */
private function matchHost($_string= '') private function matchHost($_string = '')
{ {
if (empty($_string)) { if (empty($_string)) {
return false; return false;
} }
if ($this->isHttp($_string)) { if ($this->isHttp($_string)) {
$_= str_replace('http://', '', $_string); $_ = str_replace('http://', '', $_string);
$hostAndUrls = explode('/', $_string); $hostAndUrls = explode('/', $_string);
$this->host = array_shift($hostAndUrls); $this->host = array_shift($hostAndUrls);
$_= implode('/', $hostAndUrls); $_ = implode('/', $hostAndUrls);
} else if ($this->isHttps($_string)) { } else if ($this->isHttps($_string)) {
$_= str_replace('https://', '', $_string); $_ = str_replace('https://', '', $_string);
$this->setIsSSL(true); $this->setIsSSL(true);
$hostAndUrls = explode('/', $_string); $hostAndUrls = explode('/', $_string);
$this->host = array_shift($hostAndUrls); $this->host = array_shift($hostAndUrls);
$_= implode('/', $hostAndUrls); $_ = implode('/', $hostAndUrls);
} else if (empty($this->host)) { } else if (empty($this->host)) {
$hostAndUrls = explode('/', $_string); $hostAndUrls = explode('/', $_string);
$this->host = array_shift($hostAndUrls); $this->host = array_shift($hostAndUrls);
$_= implode('/', $hostAndUrls); $_ = implode('/', $hostAndUrls);
} }
if (strpos($this->host, ':') !== false) { if (strpos($this->host, ':') !== false) {
@@ -692,7 +692,9 @@ class HttpClient
} }
if ($this->method === self::POST) { if ($this->method === self::POST) {
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->mergeParams($data)); if (!is_string($data)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->mergeParams($data));
}
} }
$output = curl_exec($ch); $output = curl_exec($ch);