Skip to content

Commit 5f69a2e

Browse files
authored
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
1 parent 7b10889 commit 5f69a2e

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/Executor/Server.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,10 @@ private function handleClientRequests(): void
149149

150150
private function readClientRequest($clientSocket)
151151
{
152-
$request = '';
153-
while (($chunk = @fread($clientSocket, 1024)) !== false) {
154-
$request .= $chunk;
155-
if (strpos($request, "\r\n\r\n") !== false) {
156-
break;
157-
}
158-
}
152+
$request = stream_get_contents($clientSocket);
159153

160-
if ($chunk === false && !feof($clientSocket)) {
161-
throw new Exception("Socket read failed");
154+
if ($request === false) {
155+
throw new Exception('Socket read failed');
162156
}
163157

164158
return $request;

0 commit comments

Comments
 (0)