ServicePointManager.Expect100Continue 属性

定义

获取或设置一个 Boolean 值,该值确定是否使用 100-Continue 行为。

public:
 static property bool Expect100Continue { bool get(); void set(bool value); };
public static bool Expect100Continue { get; set; }
static member Expect100Continue : bool with get, set
Public Shared Property Expect100Continue As Boolean

属性值

若要启用 100-Continue 行为,则为 true。 默认值为 true

示例

下面的代码示例设置此属性。

ServicePointManager::UseNagleAlgorithm = true;
ServicePointManager::Expect100Continue = true;
ServicePointManager::CheckCertificateRevocationList = true;
ServicePointManager::DefaultConnectionLimit = ServicePointManager::DefaultPersistentConnectionLimit;
ServicePointManager.UseNagleAlgorithm = true;
ServicePointManager.Expect100Continue = true;
ServicePointManager.CheckCertificateRevocationList = true;
ServicePointManager.DefaultConnectionLimit = ServicePointManager.DefaultPersistentConnectionLimit;
ServicePointManager.UseNagleAlgorithm = True
ServicePointManager.Expect100Continue = True
ServicePointManager.CheckCertificateRevocationList = True
ServicePointManager.DefaultConnectionLimit = _
    ServicePointManager.DefaultPersistentConnectionLimit

注解

当此属性设置为 true时,使用 100-Continue 行为。 如果 Expect100Continue 属性为 ContentLengthtrue 且 属性大于零或 SendChunked 属性为 true,则使用 PUTPOST 方法的客户端请求将向请求添加 Expect 标头。 客户端预期会收到来自服务器的 100-Continue 响应,以指示客户端应发送要发布的数据。 当服务器基于请求标头拒绝请求时,此机制允许客户端避免通过网络发送大量数据。

例如,假定 Expect100Continue 属性为 false。 当请求发送到服务器时,它将包括数据。 如果在读取请求标头后,服务器需要身份验证,并且必须发送 401 响应,则客户端必须使用适当的身份验证标头重新发送数据。

如果此属性为 true,则请求标头将发送到服务器。 如果服务器未拒绝请求,则会发送 100-Continue 响应,指示可以传输数据。 如果服务器需要身份验证,如前面的示例所示,它会发送 401 响应,并且客户端未不必要地传输数据。

更改此属性的值不会影响现有 ServicePoint 对象。 只有更改后创建的新 ServicePoint 对象才会受到影响。

即使此属性设置为 true,也不对 HTTP 1.0 请求使用 100-Continue 行为。

IETF RFC 2616 第 10.1.1 节中全面介绍了“预期 100-Continue”行为。

适用于

另请参阅