Skip to content

Commit

Permalink
Fix HTTP Pool key for HTTPS proxy tunneled connections (CONNECT method)
Browse files Browse the repository at this point in the history
  • Loading branch information
redapple committed Apr 8, 2016
1 parent 0ede017 commit 3e48cd0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion scrapy/core/downloader/handlers/http11.py
Expand Up @@ -127,7 +127,8 @@ def processProxyResponse(self, bytes):
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."""
Expand Down Expand Up @@ -193,6 +194,14 @@ def _getEndpoint(self, scheme, host, port):
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):
Expand Down

0 comments on commit 3e48cd0

Please sign in to comment.