How to disable the "Expect: 100 continue" header in HttpWebRequest for a single request?
The HttpWebRequest
class has a property called ServicePoint
which can be used to change this setting for a specific request. For example:
var req = (HttpWebRequest) WebRequest.Create(...);
req.ServicePoint.Expect100Continue = false;
If you also need to set a proxy, make sure to do that first. Otherwise Expect100Continue will be reverted to true again. So:
HttpWebRequest webRequest = WebRequest.CreateHttp(_url);
webRequest.Proxy = new WebProxy(_proxyHost, _proxyPort);
webRequest.ServicePoint.Expect100Continue = false;