Proxy support for HTTPS connection pool #1050
Open
+311
−68
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Connection pools are really effective. This PR makes them work through a proxy as well.
When establishing an HTTPS connection through a proxy a connection is first made with the proxy and then a second connection, a tunnel, is established with the target host. This second connection is kept in a pool whereas the connection with the proxy is not kept in the pool.
Later, when a subsequent connection is made with the same target host it could reuse the tunnel. Unfortunately the tunnel isn't found when looking in the pool for available connections. The reason is that the
sslupgrade
function creates a newConnection
with a differentconnectionkey
. This mismatch between keys causesnewconnection
to not find the reusable tunnel connection, even though we readily keep the tunnel alive sitting there just waiting to be reused.In this PR,
newtunnelconnection
uses aconnectionkey
that can be reused as expected.Does this look like the right approach for this kind of functionality?