|
|
@ -6,8 +6,6 @@ namespace Yggverse\Nex\Client; |
|
|
|
|
|
|
|
|
|
|
|
class Request |
|
|
|
class Request |
|
|
|
{ |
|
|
|
{ |
|
|
|
private ?string $_ip = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private string $_host; |
|
|
|
private string $_host; |
|
|
|
private int $_port; |
|
|
|
private int $_port; |
|
|
|
private string $_path; |
|
|
|
private string $_path; |
|
|
@ -15,7 +13,7 @@ class Request |
|
|
|
|
|
|
|
|
|
|
|
private array $_options = []; |
|
|
|
private array $_options = []; |
|
|
|
|
|
|
|
|
|
|
|
public function __construct(string $url, ?string $ip = null) |
|
|
|
public function __construct(string $url) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ($host = parse_url($url, PHP_URL_HOST)) |
|
|
|
if ($host = parse_url($url, PHP_URL_HOST)) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -70,13 +68,6 @@ class Request |
|
|
|
'' |
|
|
|
'' |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($ip && false !== filter_var($ip, FILTER_VALIDATE_IP)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$this->setResolvedHost( |
|
|
|
|
|
|
|
$ip |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setOptions(array $value): void |
|
|
|
public function setOptions(array $value): void |
|
|
@ -129,16 +120,6 @@ class Request |
|
|
|
return $this->_query; |
|
|
|
return $this->_query; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setResolvedHost(?string $value): void |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$this->_ip = $value; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getResolvedHost(): ?string |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return $this->_ip; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getResponse( |
|
|
|
public function getResponse( |
|
|
|
int $timeout = 30, // socket timeout, useful for offline resources |
|
|
|
int $timeout = 30, // socket timeout, useful for offline resources |
|
|
|
?int $limit = null, // content length, null for unlimited |
|
|
|
?int $limit = null, // content length, null for unlimited |
|
|
@ -151,7 +132,7 @@ class Request |
|
|
|
$connection = stream_socket_client( |
|
|
|
$connection = stream_socket_client( |
|
|
|
sprintf( |
|
|
|
sprintf( |
|
|
|
'tcp://%s:%d', |
|
|
|
'tcp://%s:%d', |
|
|
|
$this->_ip ? $this->_ip : $this->_host, |
|
|
|
$this->_host, |
|
|
|
$this->_port |
|
|
|
$this->_port |
|
|
|
), |
|
|
|
), |
|
|
|
$code, |
|
|
|
$code, |
|
|
|