简体   繁体   English

期望:100-继续

[英]Expect: 100-continue

There are a lot of questions on this topic, but - they gave me no answer.关于这个话题有很多问题,但是 - 他们没有给我答案。

As from advices - there is one to set ServicePointManager.Expect100Continue = false .根据建议 - 有一个设置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.有一些建议如何设置它,但它似乎不起作用。

Here is the code:这是代码:

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);

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 .问题是,在这一点上,“requestStream.Write” - header Expect: 100-continue仍然被添加,但它不应该根据我在这里阅读的建议: C# Expect100Continue header request

You can do it this way :你可以这样做:

_request.ServicePoint.Expect100Continue = false;

This will disable the Expect: 100-continue for a particular HttpWebRequest instance.这将禁用特定HttpWebRequest实例的Expect: 100-continue

When this property is set to true, client requests that use the POST method expect to receive a 100-Continue response from the server to indicate that the client should send the data to be posted.当此属性设置为 true 时,使用 POST 方法的客户端请求期望从服务器接收 100-Continue 响应,以指示客户端应发送要发布的数据。 This mechanism allows clients to avoid sending large amounts of data over the network when the server, based on the request headers, intends to reject the request.当服务器根据请求标头打算拒绝请求时,此机制允许客户端避免通过网络发送大量数据。

ServicePointManager.Expect100Continue = true; ServicePointManager.Expect100Continue = true;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Windows应用商店应用中使用WCF时禁用Expect:100-Continue - How to disable Expect:100-Continue when using WCF in Windows Store App C#Owin自我托管-预期标头100-继续 - C# Owin Self Host - Expected header 100-continue webclient 和 expect100continue - webclient and expect100continue 从Web API控制器重定向POST请求时,处理100-继续 - Handling 100-continue when redirecting a POST request from a Web API controller 如何在WinRT的HttpWebRequest中禁用“Expect:100 continue”标头 - How to disable the “Expect: 100 continue” header in WinRT's HttpWebRequest "如何为单个请求禁用 HttpWebRequest 中的“期望:100 继续”标头?" - How to disable the "Expect: 100 continue" header in HttpWebRequest for a single request? C#Expect100Continue标头请求 - C# Expect100Continue header request Windows Store应用程序的ServicePoint.Expect100Continue - ServicePoint.Expect100Continue for Windows Store Apps 当 Expect100Continue header 被禁用时,HttpWebRequest 会引入显着延迟 - HttpWebRequest introduces significant latency when the Expect100Continue header is disabled 将ServicePointManager.Expect100Continue = false设置一次后,是否仍在整个应用程序范围内设置? - Does ServicePointManager.Expect100Continue = false remain set application-wide after setting it once?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM