From d5e919f4cb929585c14baf173820027458dcf95d Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Sat, 5 Jan 2019 19:48:13 +0000 Subject: [PATCH] dcd.common.messages: Fix spurious "Could not unpack the response" errors recv() is allowed to return less than the indicated buffer size, even when more data may still become available. Exiting the read loop on such conditions caused fragmented responses to be partially read, then failing to decode. To read the entire response, we need to keep reading until the connection is properly closed (recv() returns zero). --- src/dcd/common/messages.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dcd/common/messages.d b/src/dcd/common/messages.d index 1bda554..a4e6913 100644 --- a/src/dcd/common/messages.d +++ b/src/dcd/common/messages.d @@ -220,7 +220,7 @@ AutocompleteResponse getResponse(Socket socket) if (bytesReceived == 0) break; unpacker.feed(buffer[0..bytesReceived]); - } while (bytesReceived == buffer.length); + } while (true); if (unpacker.size == 0) throw new Exception("Server closed the connection, 0 bytes received");