Skip to content

Commit

Permalink
Merge pull request #112 from renoki-co/fix/http-to-ws
Browse files Browse the repository at this point in the history
[fix] HTTP protocol to WS protocol fix
  • Loading branch information
rennokki authored Aug 3, 2021
2 parents 8654bf3 + df18f5a commit d0f198b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/KubernetesCluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,19 @@ protected function makeRequest(string $method, string $path, string $payload = '
*/
protected function makeWsRequest(string $path, Closure $callback = null, array $query = ['pretty' => 1])
{
$url = str_replace(
['https://', 'http://'],
['wss://', 'ws://'],
$this->getCallableUrl($path, $query)
);
$url = $this->getCallableUrl($path, $query);

// Replace the HTTP protocol prefixes with WS protocols.
$replaces = [
'https://' => 'wss://',
'http://' => 'ws://',
];

foreach ($replaces as $search => $replace) {
if (Str::startsWith($url, $search)) {
$url = Str::replaceFirst($search, $replace, $url);
}
}

[$loop, $ws] = $this->getWsClient($url);

Expand Down

0 comments on commit d0f198b

Please sign in to comment.