如何禁用 WinRT 的 HttpWebRequest 中的“Expect: 100 continue"标头 [英] How to disable the “Expect: 100 continue” header in WinRT's HttpWebRequest
本文介绍了如何禁用 WinRT 的 HttpWebRequest 中的“Expect: 100 continue"标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个应用程序,由于遗留代码的原因,我无法为新的 HttpClient
升级,所以我正在使用 HttpWebRequests
.
I'm developing an app that for legacy code reasons I can't upgrade for the new HttpClient
so I'm using HttpWebRequests
.
在 .NET 4 中,我们可以使用 ServicePoint.Expect100Continue
属性,但在 WinRT 上它不可用.
In .NET 4 we could deactivate the Expect header (on posts requests) using ServicePoint.Expect100Continue
property, but on WinRT it's not available.
如何在 WinRT 上实现这一点?
How can this be accomplished on WinRT?
System.Net.ServicePointManager.Expect100Continue
也不可用.
推荐答案
var c = new HttpClient();
c.DefaultRequestHeaders.ExpectContinue = false;
这篇关于如何禁用 WinRT 的 HttpWebRequest 中的“Expect: 100 continue"标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文