I need to send such a request using HttpWebRequest:
POST https://sap.site.com.mx/sap/bw/BEx?SAP-LANGUAGE=ES&PAGENO=1&CMD=PROCESS_VARIABLES&REQUEST_NO=0&CMD=PROCESS_VARIABLES&SUBCMD=VAR_SUBMIT&VARID= HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: es-MX,es;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
However, I cannot send the Connection header. This is my code:
HttpWebRequest request = CreateWebRequestObject(url);
request.CookieContainer = this.cc;
request.UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2";
request.Headers.Add("Accept-Encoding", "gzip, deflate");
request.Headers.Add("Accept-Language", " es-MX,es;q=0.8,en-us;q=0.5,en;q=0.3");
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.KeepAlive = true;
request.ServicePoint.Expect100Continue = false;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = buffer.Length;
using (Stream stream = request.GetRequestStream())
stream.Write(buffer, 0, buffer.Length);
But, when I check the request in Fiddler, the Connection property does not appear.
In addition, these messages do not work for me:
How to send the connection header correctly?
UPDATE
This adds Keep-Alive using HTTP / 1.0.
request.ProtocolVersion = HttpVersion.Version10;
//request.KeepAlive = true; // not necessary
When the ProtocolVersion property changes to HttpVersion.Version11, the Keep-Alive header is not sent:
request.ProtocolVersion = HttpVersion.Version11;
request.KeepAlive = true;
How can I send a Keep-Alive header using Http / 1.1?