开发者

How to turn off persistent proxy connections

开发者 https://www.devze.com 2023-02-09 23:46 出处:网络
This is a follow up on this question on how to turn of Connection: Keep-Alive headers on HttpWebRequest.

This is a follow up on this question on how to turn of Connection: Keep-Alive headers on HttpWebRequest.

I have successfully disabled the Connection: Keep-Alive h开发者_StackOverflow社区eaders from my Web service call, but when I use a proxy it also sends a CONNECT xxx.xxxxx.xx:443 HTTP/1.1 to the proxy before the call is sent to the server.

With this CONNECT call a bunch of headers are sent:

System.Net Information: 0 : [5420] ConnectStream#33166512 - Sending headers

{

Proxy-Authorization: Basic xxxxxxxxxxxxxxx==

Host: xxx.xxxxx.xx

Proxy-Connection: Keep-Alive

}.

I want to get rid of the Keep-Alive and change it to Close but cannot find out how to control this header. How do I change or disable the Proxy-Connection header?

Edit:

Googleing around I figured that I have to set the webRequest.Connection = "Close"; or webRequest.Connection = null;, but those results in an argument exception.


Appareantly it is not possible to change the Proxy-Connection header.

The result that I was trying to achieve (close the tcp connection to the proxy before the load-balancer between client and proxy kills it after 2 minutes of inactivity) was realized by setting

ServicePointManager.MaxServicePointIdleTime = 100000;

The ServicePointManager closes the underlying connection after 100 seconds, well before it is killed by the load-balancer and creates a new one when necessary.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号