How to send KeepAlive header correctly in c#?

后端 未结 2 1980

I need to send a request like this using HttpWebRequest:

POST https://sap.site.com.mx/sap/bw/BEx?SAP-LANGUAGE=ES&PAGENO=1&CMD=PROCESS_VARIABLES&REQUE         


        
相关标签:
2条回答
  • 2021-02-10 07:57

    When using HTTP/1.1, Keep-Alive is on by default.Setting KeepAlive to false may result in sending a Connection: Close header to the server.

    0 讨论(0)
  • 2021-02-10 08:12

    I had the same bug with the very similar code, and setting

    var sp = req.ServicePoint;
    var prop = sp.GetType().GetProperty("HttpBehaviour", BindingFlags.Instance | BindingFlags.NonPublic);
    prop.SetValue(sp, (byte)0, null);
    

    DID fix it. Are you sure that you do execute this code each time you create httpwebrequest?

    0 讨论(0)
提交回复
热议问题