Reuse http connection

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

  • When I use HttpWebRequest to send something to any server twice from the same application, is this connection (optional) reused? Thus, the server will see both requests as outgoing from the same connection, although in my application they represent different logical requests.

  • If so, can this behavior be disabled?

  • What about connections using / ssl authentication, are they also reused? If I provide different credentials / policies for each request, this could be a security hole.

+3
source share
2 answers

Reusing a connection uses HTTP Keep-alive, which is an HTTP / 1.1 feature. Using HTTP Keep-alive, one TCP connection is used to process several HTTP requests in sequence, so one of them saves time to open a new TCP connection for each request. Each HTTP request in itself is independent again, so authentication and the like will not be reused automatically.

+3
source

As the RFC says at http://tools.ietf.org/html/rfc2616#section-8.1 HTTP header: Connection: Keep-Alive

- this is what is used by Http 1.0 because the connection was not permanent.

http 1.1 , , .

+2

Source: https://habr.com/ru/post/1722270/


All Articles