Scrapy, a fast high-level web crawling & scraping framework for Python.
Fix HTTP Pool key for HTTPS proxy tunneled connections (CONNECT method)
Paul Tremberth86e4442d177e
diff --git a/scrapy/core/downloader/handlers/http11.py b/scrapy/core/downloader/handlers/http11.pyindex 9cb659e67..157432ee1 100644--- a/scrapy/core/downloader/handlers/http11.py+++ b/scrapy/core/downloader/handlers/http11.py@@ -127,7 +127,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."""@@ -193,6 +194,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):