How to disable the “Expect: 100 continue” header in HttpWebRequest for a single request?

前端 未结 2 1837
甜味超标
甜味超标 2021-02-01 12:57

HttpWebRequest automatically appends an Expect: 100-continue header for POST requests. Various sources around the internet suggest that this can be dis

2条回答
  •  花落未央
    2021-02-01 13:43

    The HttpWebRequest class has a property called ServicePoint which can be used to change this setting for a specific request. For example:

    var req = (HttpWebRequest) WebRequest.Create(...);
    req.ServicePoint.Expect100Continue = false;
    

提交回复
热议问题