@@ -135,7 +135,8 @@ def processProxyResponse(self, bytes):
135
135
self ._tunnelReadyDeferred .callback (self ._protocol )
136
136
else :
137
137
self ._tunnelReadyDeferred .errback (
138
- TunnelError ('Could not open CONNECT tunnel.' ))
138
+ TunnelError ('Could not open CONNECT tunnel with proxy %s:%s' % (
139
+ self ._host , self ._port )))
139
140
140
141
def connectFailed (self , reason ):
141
142
"""Propagates the errback to the appropriate deferred."""
@@ -201,6 +202,14 @@ def _getEndpoint(self, scheme, host, port):
201
202
self ._contextFactory , self ._connectTimeout ,
202
203
self ._bindAddress )
203
204
205
+ def _requestWithEndpoint (self , key , endpoint , method , parsedURI ,
206
+ headers , bodyProducer , requestPath ):
207
+ # proxy host and port are required for HTTP pool `key`
208
+ # otherwise, same remote host connection request could reuse
209
+ # a cached tunneled connection to a different proxy
210
+ key = key + self ._proxyConf
211
+ return super (TunnelingAgent , self )._requestWithEndpoint (key , endpoint , method , parsedURI ,
212
+ headers , bodyProducer , requestPath )
204
213
205
214
206
215
class ScrapyAgent (object ):
0 commit comments