make sure large requests are properly sent

This commit is contained in:
WebFreak001 2022-11-12 04:46:58 +01:00 committed by Jan Jurzitza
parent 758c78145f
commit cc8f088eef
1 changed files with 9 additions and 1 deletions

View File

@ -205,7 +205,15 @@ bool sendRequest(Socket socket, AutocompleteRequest request)
auto messageLength = message.length;
messageBuffer[0 .. size_t.sizeof] = (cast(ubyte*) &messageLength)[0 .. size_t.sizeof];
messageBuffer[size_t.sizeof .. $] = message[];
return socket.send(messageBuffer) == messageBuffer.length;
size_t i;
while (i < messageBuffer.length)
{
auto sent = socket.send(messageBuffer[i .. $]);
if (sent == Socket.ERROR)
return false;
i += sent;
}
return true;
}
/**