HttpClient.DefaultRequestHeaders.ExpectContinue。 ExpectContinue 服务于什么目的以及在什么条件下将其设置为 true 或 false。
HttpClient.DefaultRequestHeaders.ExpectContinue. What purpose does ExpectContinue serve and under what conditions is it set to true or false.
我一直在研究一些代码并遇到了
private readonly HttpClient _client;
_client = new HttpClient(clientHandler);
_client.DefaultRequestHeaders.ExpectContinue = false;
msdn (https://goo.gl/IoZlB1) doesn't contain much information about ExpectContinue. Also the HttpRequestHeader Enumeration on msdn (https://goo.gl/IoZlB1) 将 Expect 描述为
The Expect header, which specifies particular server behaviors that
are required by the client.
我希望有人可以阐明 ExpectContinue。它的目的是什么,如果它是真或假会发生什么?
继续状态主要用于先发送请求头,看服务器是否允许(接受)请求。如果服务器说 OK,它会发送 100-continue 并且客户端继续处理请求正文。否则,服务器响应 417(预期失败)。
假设您要将一个 1 GB 的文件上传到服务器上的特定文件夹。如果直接开始传输,服务器不接受大于512MB的文件或文件夹不存在,服务器将不会接受该文件,传输对双方来说都是一种资源浪费。
查看 W3C 文档here
请参阅第 8.2.3 节使用 100(继续)状态
我一直在研究一些代码并遇到了
private readonly HttpClient _client;
_client = new HttpClient(clientHandler);
_client.DefaultRequestHeaders.ExpectContinue = false;
msdn (https://goo.gl/IoZlB1) doesn't contain much information about ExpectContinue. Also the HttpRequestHeader Enumeration on msdn (https://goo.gl/IoZlB1) 将 Expect 描述为
The Expect header, which specifies particular server behaviors that are required by the client.
我希望有人可以阐明 ExpectContinue。它的目的是什么,如果它是真或假会发生什么?
继续状态主要用于先发送请求头,看服务器是否允许(接受)请求。如果服务器说 OK,它会发送 100-continue 并且客户端继续处理请求正文。否则,服务器响应 417(预期失败)。
假设您要将一个 1 GB 的文件上传到服务器上的特定文件夹。如果直接开始传输,服务器不接受大于512MB的文件或文件夹不存在,服务器将不会接受该文件,传输对双方来说都是一种资源浪费。
查看 W3C 文档here
请参阅第 8.2.3 节使用 100(继续)状态