Merge pull request #1943 from redapple/backport-1.1-pr1912

[backport][1.1] Fix HTTP Pool key for HTTPS proxy tunneled connections (PR #1912)
This commit is contained in:
Paul Tremberth 2016-04-20 17:19:39 +02:00
commit 6e4742755e
1 changed files with 10 additions and 1 deletions

View File

@ -135,7 +135,8 @@ class TunnelingTCP4ClientEndpoint(TCP4ClientEndpoint):
self._tunnelReadyDeferred.callback(self._protocol)
else:
self._tunnelReadyDeferred.errback(
TunnelError('Could not open CONNECT tunnel.'))
TunnelError('Could not open CONNECT tunnel with proxy %s:%s' % (
self._host, self._port)))
def connectFailed(self, reason):
"""Propagates the errback to the appropriate deferred."""
@ -201,6 +202,14 @@ class TunnelingAgent(Agent):
self._contextFactory, self._connectTimeout,
self._bindAddress)
def _requestWithEndpoint(self, key, endpoint, method, parsedURI,
headers, bodyProducer, requestPath):
# proxy host and port are required for HTTP pool `key`
# otherwise, same remote host connection request could reuse
# a cached tunneled connection to a different proxy
key = key + self._proxyConf
return super(TunnelingAgent, self)._requestWithEndpoint(key, endpoint, method, parsedURI,
headers, bodyProducer, requestPath)
class ScrapyAgent(object):