From 06e40b7bb981786b15e6df6e0a5ea478b3af9eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Jensen?= Date: Sat, 17 Apr 2021 15:32:45 +0200 Subject: [PATCH] Fix for persistent connection in client --- lib/Client.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/Client.php b/lib/Client.php index d6bfeab..8cefaaa 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -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']); @@ -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}";