Skip to content

Commit

Permalink
Fix for persistent connection in client
Browse files Browse the repository at this point in the history
  • Loading branch information
sirn-se committed Apr 17, 2021
1 parent caa1610 commit 06e40b7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ protected function connect(): void
throw new ConnectionException($error);
}

$address = "{$scheme}://{$host}{$path_with_query}";

if (!$persistent || ftell($this->socket) == 0) {
// Set timeout on the stream as well.
stream_set_timeout($this->socket, $this->options['timeout']);
Expand Down Expand Up @@ -177,10 +179,6 @@ function ($key, $value) {
// Get server response header (terminated with double CR+LF).
$response = stream_get_line($this->socket, 1024, "\r\n\r\n");

/// @todo Handle version switching

$address = "{$scheme}://{$host}{$path_with_query}";

// Validate response.
if (!preg_match('#Sec-WebSocket-Accept:\s(.*)$#mUi', $response, $matches)) {
$error = "Connection to '{$address}' failed: Server sent invalid upgrade response: {$response}";
Expand Down

0 comments on commit 06e40b7

Please sign in to comment.