Wednesday, March 25, 2009

How to disable passing of HTTP header "Expect: 100-continue" using HttpWebRequest in .NET Framework in C#?

How to disable passing of HTTP header "Expect: 100-continue" using HttpWebRequest in .NET Framework in C#?
По умолчанию, при выполнении веб-запроса, используя класс HttpWebRequest, .NET Framework добавляет HTTP заголовок (HTTP header) "Expect: 100-continue". Для того, чтобы запретить формирование этого заголовка нужно сделать следующее:

As default when You use HttpWebRequest class to execute web-requests it appends HTTP header "Expect: 100-continue" to it's headers collection. To disable passing of HTTP header "Expect: 100-continue" using HttpWebRequest You can do following:


HttpWebRequest myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create("http://a-kicker.blogspot.com");
myHttpWebRequest.ServicePoint.Expect100Continue = false;

No comments: