@@ -127,7 +127,8 @@ def processProxyResponse(self, bytes):
127
127
self ._tunnelReadyDeferred .callback (self ._protocol )
128
128
else :
129
129
self ._tunnelReadyDeferred .errback (
130
- TunnelError ('Could not open CONNECT tunnel.' ))
130
+ TunnelError ('Could not open CONNECT tunnel with proxy %s:%s' % (
131
+ self ._host , self ._port )))
131
132
132
133
def connectFailed (self , reason ):
133
134
"""Propagates the errback to the appropriate deferred."""
@@ -193,6 +194,14 @@ def _getEndpoint(self, scheme, host, port):
193
194
self ._contextFactory , self ._connectTimeout ,
194
195
self ._bindAddress )
195
196
197
+ def _requestWithEndpoint (self , key , endpoint , method , parsedURI ,
198
+ headers , bodyProducer , requestPath ):
199
+ # proxy host and port are required for HTTP pool `key`
200
+ # otherwise, same remote host connection request could reuse
201
+ # a cached tunneled connection to a different proxy
202
+ key = key + self ._proxyConf
203
+ return super (TunnelingAgent , self )._requestWithEndpoint (key , endpoint , method , parsedURI ,
204
+ headers , bodyProducer , requestPath )
196
205
197
206
198
207
class ScrapyAgent (object ):
0 commit comments