Skip to content

Commit

Permalink
add stream context options support
Browse files Browse the repository at this point in the history
  • Loading branch information
yggverse committed Apr 6, 2024
1 parent 75685f3 commit 54ad13e
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/Client/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ class Request
private string $_path;
private string $_query;

private array $_options =
[
'ssl' =>
[
'verify_peer' => false,
'verify_peer_name' => false
]
];

public function __construct(string $url)
{
if ($host = parse_url($url, PHP_URL_HOST))
Expand Down Expand Up @@ -68,6 +77,16 @@ public function __construct(string $url)
}
}

public function setOptions(array $value): void
{
$this->_options = $value;
}

public function getOptions(): array
{
return $this->_options;
}

public function setHost(string $value): void
{
$this->_host = $value;
Expand Down Expand Up @@ -128,13 +147,7 @@ public function getResponse(
$timeout,
STREAM_CLIENT_CONNECT,
stream_context_create(
[
'ssl' =>
[
'verify_peer' => false,
'verify_peer_name' => false
]
]
$this->_options
)
);

Expand Down

0 comments on commit 54ad13e

Please sign in to comment.