http connection reuse
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) reused? So the server would see both requests as coming from the same connection even though in my application they are different logical requests.
If yes, can this behavior be turned off?
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.
精彩评论