zoukankan      html  css  js  c++  java
  • Http Notes

    HttpWebRequest.ServicePoint.Expect100Continue

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url)

    request.ServicePoint.Expect100Continue

    // 摘要:

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

    // 返回结果:

    //     如果 POST 请求需要 100-Continue 响应,则为 true;否则为 false。默认值为 true。

    解析:

    在使用curl做POST的时候, 当要POST的数据大于1024字节的时候, curl并不会直接就发起POST请求, 而是会分为两步:

    1、发送一个请求, 包含一个Expect:100-continue, 询问Server使用愿意接受数据;2、在接收到Server返回的100-continue应答以后, 才把数据POST给Server。

    并不是所有的Server都会正确应答100-continue, 比如 lighttpd, 就会返回417 “Expectation Failed”, 则会造成逻辑出错。

    解决办法:

    HttpWebRequest request = WebRequest.Create(uri.Uri) as HttpWebRequest;

    reqrequest.ServicePoint.Expect100Continue = false; // 取消100-continue

  • 相关阅读:
    【BZOJ4033】【HAOI2015】树上染色
    【BZOJ1040】【ZJOI2008】骑士
    【BZOJ3573】【HNOI2014】米特运输
    【BZOJ1060】【ZJOI2007】时态同步
    17-10-11模拟赛
    17-10-05模拟赛
    17-09-29模拟赛
    17-09-21模拟赛
    17-09-20模拟赛
    17-09-15模拟赛
  • 原文地址:https://www.cnblogs.com/huhunet/p/7402925.html
Copyright © 2011-2022 走看看