http: fix incomplete content read
This commit is contained in:
parent
9834d350ec
commit
f4862e6c8a
1 changed files with 11 additions and 2 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue