期待:100-继续 [英] Expect: 100-continue
问题描述
关于这个主题有很多问题,但是 - 他们没有给我任何答案。
There are a lot of questions on this topic, but - they gave me no answer.
从建议开始 - 有一个设置 ServicePointManager.Expect100Continue = false
。但这是不可接受的,因为这将是一个模块,与其他十几个同步工作。如此可接受的解决方案 - 是每个连接属性。有建议如何设置它,但它似乎没有工作。
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.
这是代码:
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);
问题是,在requestStream.Write点 - 标题期望:100-continue
仍然被添加,但它不应该根据我在这里读到的建议: C#Expect100Continue标头请求。
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.
推荐答案
你可以这样做:
_request.ServicePoint.Expect100Continue = false;
这将禁用 Expect:100-continue
对于特定的 HttpWebRequest
实例。
This will disable the Expect: 100-continue
for a particular HttpWebRequest
instance.
这篇关于期待:100-继续的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!