From f4862e6c8a201085a41e5a18b8e8863cd0f4423d Mon Sep 17 00:00:00 2001 From: uwaa Date: Sat, 30 Nov 2024 11:18:33 +0000 Subject: [PATCH] http: fix incomplete content read --- HTTP/HttpStream.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/HTTP/HttpStream.cs b/HTTP/HttpStream.cs index 02d06f1..0b9005f 100644 --- a/HTTP/HttpStream.cs +++ b/HTTP/HttpStream.cs @@ -75,11 +75,20 @@ class HttpStream : IDisposable } } - public ValueTask Read(Memory buffer) + public async ValueTask Read(Memory buffer) { try { - return Buffer.ReadAsync(buffer); + int index = 0; + while (index < buffer.Length) + { + int count = await Buffer.ReadAsync(buffer[index..]); + if (count == 0) + break; + + index += count; + } + return index; } catch (IOException e) {