开发者

http connection reuse

开发者 https://www.devze.com 2022-12-10 16:23 出处:网络
I would like to better understand how .Net http connection reuse works. When I use HttpWebRequest to send something to some server twice from the same appdomain, is the connection (optionally) reuse

I would like to better understand how .Net http connection reuse works.

  1. When I use HttpWebRequest to send something to some server twice from the same appdomain, is the connection (optionally) reused? So the server would see both requests as coming from the same connection even though in my application they are different logical requests.

  2. If yes, can this behavior be turned off?

  3. What about connections that use authentication/ssl - are they also also reused? If I supply different credentials/poli开发者_开发技巧cy for each request this can be a security hole.


The connection re-use is using HTTP Keep-alive which is a feature of HTTP/1.1. By using HTTP Keep-alive one TCP connection is used for handling multiple HTTP requests sequentially so one saves time to open a new TCP connection for every request. Each HTTP request itself is then again independent so authentification and similar won't be re-used automatically.


As it says the RFC in https://www.rfc-editor.org/rfc/rfc2616#section-8.1 The HTTP header: Connection: Keep-Alive

is something used by Http 1.0, because connection weren't persistent.

as of http 1.1 all connections are persistent by default, which means that this header is not used anymore.

0

精彩评论

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

关注公众号