Fix issue where stream read is terminated prematurely (#4032)

* Update Server.php

* Update Server.php

* Update Server.php

* Fix issue where stream read is terminated prematurely
This commit is contained in:
Peter Elmered 2025-03-06 22:38:50 +01:00 committed by GitHub
parent 7b108897ba
commit 5f69a2e0a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -149,16 +149,10 @@ class Server
private function readClientRequest($clientSocket)
{
$request = '';
while (($chunk = @fread($clientSocket, 1024)) !== false) {
$request .= $chunk;
if (strpos($request, "\r\n\r\n") !== false) {
break;
}
}
$request = stream_get_contents($clientSocket);
if ($chunk === false && !feof($clientSocket)) {
throw new Exception("Socket read failed");
if ($request === false) {
throw new Exception('Socket read failed');
}
return $request;