Skip to content

Commit

Permalink
[fix]修正TinyHttpClient对大型响应包的支持。响应类型为chunked时,有可能第一个包只有头部,没有任何body内容,需…
Browse files Browse the repository at this point in the history
…要先读取一个包。下载站改版升级后,响应头带有cookie比较大。
  • Loading branch information
nnhy committed May 24, 2024
1 parent 87f33a6 commit a402c9e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion NewLife.Core/Http/TinyHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,12 @@ protected virtual async Task<Packet> SendDataAsync(Uri? uri, Packet? request)
}

// chunk编码
if (rs != null && rs.Count > 0 && res.Headers.TryGetValue("Transfer-Encoding", out var s) && s.EqualIgnoreCase("chunked"))
if (rs != null && res.Headers.TryGetValue("Transfer-Encoding", out var s) && s.EqualIgnoreCase("chunked"))
{
// 如果不足则读取一个chunk,因为有可能第一个响应包只有头部
if (rs.Count == 0)
rs = await SendDataAsync(null, null).ConfigureAwait(false);

res.Body = await ReadChunkAsync(rs);
}

Expand Down

0 comments on commit a402c9e

Please sign in to comment.