.net - HttpWebRequest.Proxy=null rewrite Expect100Continue -


i found crazy behavior of httpwebrequest class when u set httpwebrequest.proxy=null. @ first time rewirte expect100continue true reason. example code

        httpwebrequest webrequest1 = (httpwebrequest)webrequest.create("http://stackoverflow.com/");         webrequest1.method = "post";          webrequest1.servicepoint.expect100continue = false;         webrequest1.proxy = globalproxyselection.getemptywebproxy(); ;         console.writeline(webrequest1.servicepoint.expect100continue);          webrequest1.servicepoint.expect100continue = false;         webrequest1.proxy = null;         console.writeline(webrequest1.servicepoint.expect100continue);           webrequest1 = (httpwebrequest)webrequest.create("http://stackoverflow.com/");         webrequest1.method = "post";          webrequest1.servicepoint.expect100continue = false;         webrequest1.proxy = null;         console.writeline(webrequest1.servicepoint.expect100continue);           httpwebrequest webrequest2 = (httpwebrequest)webrequest.create("http://stackoverflow.com/");         webrequest2.method = "post";          webrequest2.servicepoint.expect100continue = false;         webrequest2.proxy = null;         console.writeline(webrequest2.servicepoint.expect100continue);          console.readline(); 

will write: true false false false

and 1 way found resolve this:

        var expect100continue = webrequest.servicepoint.expect100continue;         webrequest.proxy = null;         webrequest.servicepoint.expect100continue = expect100continue; 

can explain this?

when setting proxy property on webrequest, servicepoint recreated.

the value of expect100continue default whatever value set on servicepointmanager can configured app.config file.

at least, can see looking @ disassembly.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -