改名
This commit is contained in:
@@ -190,12 +190,15 @@ abstract class ClientAbstracts extends Component implements IClient
|
|||||||
*/
|
*/
|
||||||
public function setHost(string $host): void
|
public function setHost(string $host): void
|
||||||
{
|
{
|
||||||
if (!preg_match('/(\d{1,3}\.){4}/', $host . '.')) {
|
$this->host = $host;
|
||||||
$this->addHeader('Host', $host);
|
if ($this->use_swoole) {
|
||||||
$this->host = System::gethostbyname($host);
|
$this->host = System::gethostbyname($host);
|
||||||
} else {
|
|
||||||
$this->host = $host;
|
|
||||||
}
|
}
|
||||||
|
$this->addHeader('Host', $host);
|
||||||
|
//
|
||||||
|
// if (!preg_match('/(\d{1,3}\.){4}/', $host . '.')) {
|
||||||
|
// } else {
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -762,7 +765,7 @@ abstract class ClientAbstracts extends Component implements IClient
|
|||||||
} else if (strpos($string, '/') !== 0) {
|
} else if (strpos($string, '/') !== 0) {
|
||||||
$string = '/' . $string;
|
$string = '/' . $string;
|
||||||
}
|
}
|
||||||
return [$host, false, $string];
|
return [$host, $this->isSSL(), $string];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ class Curl extends ClientAbstracts
|
|||||||
{
|
{
|
||||||
[$host, $isHttps, $path] = $this->matchHost($path);
|
[$host, $isHttps, $path] = $this->matchHost($path);
|
||||||
|
|
||||||
|
$host = $isHttps ? 'https://' . $host : 'http://' . $host;
|
||||||
|
|
||||||
$resource = $this->do(curl_init($host . $path), $host . $path, $method);
|
$resource = $this->do(curl_init($host . $path), $host . $path, $method);
|
||||||
if ($method === self::POST && !empty($params)) {
|
if ($method === self::POST && !empty($params)) {
|
||||||
curl_setopt($resource, CURLOPT_POSTFIELDS, HttpParse::parse($params));
|
curl_setopt($resource, CURLOPT_POSTFIELDS, HttpParse::parse($params));
|
||||||
@@ -64,6 +66,8 @@ class Curl extends ClientAbstracts
|
|||||||
{
|
{
|
||||||
[$host, $isHttps, $path] = $this->matchHost($path);
|
[$host, $isHttps, $path] = $this->matchHost($path);
|
||||||
|
|
||||||
|
$host = $isHttps ? 'https://' . $host : 'http://' . $host;
|
||||||
|
|
||||||
$resource = $this->do(curl_init($host . $path), $host . $path, self::POST);
|
$resource = $this->do(curl_init($host . $path), $host . $path, self::POST);
|
||||||
|
|
||||||
curl_setopt($resource, CURLOPT_POSTFIELDS, $params);
|
curl_setopt($resource, CURLOPT_POSTFIELDS, $params);
|
||||||
|
|||||||
Reference in New Issue
Block a user