http: fix incomplete content read

This commit is contained in:
uwaa 2024-11-30 11:18:33 +00:00
parent 9834d350ec
commit f4862e6c8a

View file

@ -75,11 +75,20 @@ class HttpStream : IDisposable
}
}
public ValueTask<int> Read(Memory<byte> buffer)
public async ValueTask<int> Read(Memory<byte> 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)
{