请问 .NET Core 中如何通过 HttpClient 发送 chunked requests ?对应的请求头是 Transfer-Encoding: chunked
1 回答
慕慕森
TA贡献1856条经验 获得超17个赞
using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.TransferEncodingChunked = true; using (var ms = new MemoryStream()) { var streamContent = new StreamContent(ms); for (int i = 0; i < 100; i++) { var bytes = Encoding.UTF8.GetBytes("Hello World!"); ms.Write(bytes); ms.Flush(); var response = await httpClient.PostAsync(uri, streamContent); Console.WriteLine($"Requested {response.RequestMessage.RequestUri}...{response.StatusCode}"); } } }
- 1 回答
- 0 关注
- 926 浏览
添加回答
举报
0/150
提交
取消