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

屬性值

true 表示啟用 100-Continue 行為。 預設值是 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 行為。 如果使用 和 POST 方法的用戶端要求PUT,如果 Expect100Continue 屬性是 trueContentLength 屬性大於零,或 SendChunked 屬性為 true,則會將 Expect 標頭新增至要求。 用戶端預期會收到來自伺服器的 100-Continue 回應,以指出客戶端應該傳送要張貼的數據。 此機制可讓用戶端避免在伺服器根據要求標頭而想要拒絕要求時,透過網路傳送大量數據。

例如,假設 Expect100Continue 屬性為 false。 當要求傳送至伺服器時,它會包含數據。 如果在讀取要求標頭之後,伺服器需要驗證,而且必須傳送 401 回應,客戶端必須以適當的驗證標頭重新傳送數據。

如果此屬性為 true,則會將要求標頭傳送至伺服器。 如果伺服器尚未拒絕要求,它會傳送 100-Continue 回應訊號,指出可以傳輸數據。 如果如上述範例所示,伺服器需要驗證,它會傳送 401 回應,而且用戶端尚未不必要的傳輸數據。

變更此屬性的值不會影響現有的 ServicePoint 物件。 只有在變更之後建立的新 ServicePoint 物件才會受到影響。

即使這個屬性設定 true為 ,100-Continue 行為也不會用於 HTTP 1.0 要求。

IETF RFC 2616 第 10.1.1 節已完整描述預期 100-Continue 行為。

適用於

另請參閱