There are a lot of questions on this topic, but - they gave me no answer.
As from advices - there is one to set ServicePointManager.Expect100Continue = false
. But it is not acceptable because this will be a module, asynchroniously working along with dozen of others. So acceptable solution - is per-connection property. There are advices how to set this, but it doesn't seem to be working.
Here is the code:
var conuri = new Uri(connectionString);
var sp = ServicePointManager.FindServicePoint(conuri);
sp.Expect100Continue = false;
_request = (HttpWebRequest)WebRequest.Create(conuri);
_request.ContentType = "text/xml";
_request.Method = "POST";
_request.ContentLength = dataToSend.Length;
requestStream = _request.GetRequestStream();
requestStream.Write(dataToSend, 0, dataToSend.Length);
Problem is, that at the point "requestStream.Write" - header Expect: 100-continue
is still added, but it shouldn't according to advice I've read here: C# Expect100Continue header request.
The client will expect to receive a 100-Continue response from the server to indicate that the client should send the data to be posted. This mechanism allows clients to avoid sending large amounts of data over the network when the server, based on the request headers, intends to reject the request.
The 100 Continue status code means that the initial part of the request has been received by the server and that the client should proceed with the request or ignore the response if the request has already finished.
The Expect HTTP request header indicates expectations that need to be met by the server to handle the request successfully.
You can do it this way :
_request.ServicePoint.Expect100Continue = false;
This will disable the Expect: 100-continue
for a particular HttpWebRequest
instance.
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