Skip to content

Commit

Permalink
fixNull
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Aug 16, 2024
1 parent 63b1f4c commit 082ee95
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions NewLife.Core/Http/TinyHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,21 @@ protected virtual async Task<Packet> ReadChunkAsync(Packet body)
var total = chunk.Total;
while (total < len)
{
pk = await SendDataAsync(null, null).ConfigureAwait(false);
var pk2 = await SendDataAsync(null, null).ConfigureAwait(false);
if (pk != null)
pk.Append(pk2);
else
pk = pk2;

// 结尾的间断符号(如换行或00)。这里有可能一个数据包里面同时返回多个分片
var count = len - total;
if (count <= pk.Total)
if (pk != null && count <= pk.Total)
{
var pk2 = pk.Slice(0, count);
var pk3 = pk.Slice(0, count);

last.Append(pk2);
last = pk2;
total += pk2.Total;
last.Append(pk3);
last = pk3;
total += pk3.Total;

// 如果还有剩余,作为下一个chunk
count += 2;
Expand Down

0 comments on commit 082ee95

Please sign in to comment.