Skip to content

Commit

Permalink
Merge pull request #137 from Textalk/persistent-fix
Browse files Browse the repository at this point in the history
Fix for persistent connection in client
  • Loading branch information
sirn-se authored Apr 18, 2021
2 parents caa1610 + 06e40b7 commit 25f6e32
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 25f6e32

Please sign in to comment.