qqq
This commit is contained in:
+1
-7
@@ -327,15 +327,9 @@ abstract class ClientAbstracts implements IClient
|
|||||||
* @param string $host
|
* @param string $host
|
||||||
* @return ClientAbstracts
|
* @return ClientAbstracts
|
||||||
*/
|
*/
|
||||||
private function withHost(string $host): static
|
protected function withHost(string $host): static
|
||||||
{
|
{
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
if (!preg_match('/(\d{1,3}\.){3}\d{1,3}/', $host)) {
|
|
||||||
if (class_exists(Coroutine::class) && Coroutine::getCid() > -1) {
|
|
||||||
$this->host = System::gethostbyname($host);
|
|
||||||
}
|
|
||||||
return $this->withAddedHeader('Host', $host);
|
|
||||||
}
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ declare(strict_types=1);
|
|||||||
namespace Kiri;
|
namespace Kiri;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Swoole\Coroutine;
|
||||||
use Swoole\Coroutine\Http\Client as SwowClient;
|
use Swoole\Coroutine\Http\Client as SwowClient;
|
||||||
|
use Swoole\Coroutine\System;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Client
|
* Class Client
|
||||||
@@ -33,6 +35,11 @@ class CoroutineClient extends ClientAbstracts
|
|||||||
if (!str_starts_with($path, '/')) {
|
if (!str_starts_with($path, '/')) {
|
||||||
$path = '/' . $path;
|
$path = '/' . $path;
|
||||||
}
|
}
|
||||||
|
$host = $this->getHost();
|
||||||
|
if (!preg_match('/(\d{1,3}\.){3}\d{1,3}/', $host)) {
|
||||||
|
$this->withHost(System::gethostbyname($host));
|
||||||
|
$this->withAddedHeader('Host', $host);
|
||||||
|
}
|
||||||
$this->withMethod($method)
|
$this->withMethod($method)
|
||||||
->coroutine(
|
->coroutine(
|
||||||
$path,
|
$path,
|
||||||
|
|||||||
Reference in New Issue
Block a user