I've been going through some code and have come across
private readonly HttpClient _client;
_client = new HttpClient(clientHandler);
_client.DefaultRequestHeaders.ExpectContinue = false;
The msdn (https://goo.gl/IoZlB1) doesn't contain much information about ExpectContinue. Also the HttpRequestHeader Enumeration on msdn (https://goo.gl/IoZlB1) describes Expect as
The Expect header, which specifies particular server behaviors that are required by the client.
I'm hoping if someone can shed some light on ExpectContinue. What is the purpose of it and what happens if it is true or false?
The continue status is used mostly for sending the request headers first, to see if the server will allow (accept) the request. If the server says OK, it sends a 100-continue and the client proceeds with the request body. Otherwise, server responds with 417 (Expectation Failed).
Think that you are going to upload a 1 GB file to a specific folder on a server. If you start the transfer directly and the server does not accept files bigger than 512 MB or the folder does not exist, the server will not accept the file, and the transfer will be a waste of resources for both sides.
Check the W3C documentation here
See section 8.2.3 Use of the 100 (Continue) Status
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With