Skip to content

Commit

Permalink
Support new _getEndpoint Agent signatures on Twisted 15.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
curita authored and dangra committed Feb 25, 2015
1 parent b4c454b commit 540b9bc
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions scrapy/core/downloader/handlers/http11.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from scrapy.responsetypes import responsetypes
from scrapy.core.downloader.webclient import _parse
from scrapy.utils.misc import load_object
from scrapy import twisted_version


class HTTP11DownloadHandler(object):
Expand Down Expand Up @@ -137,10 +138,19 @@ def __init__(self, reactor, proxyConf, contextFactory=None,
self._proxyConf = proxyConf
self._contextFactory = contextFactory

def _getEndpoint(self, scheme, host, port):
return TunnelingTCP4ClientEndpoint(self._reactor, host, port,
self._proxyConf, self._contextFactory, self._connectTimeout,
self._bindAddress)
if twisted_version >= (15, 0, 0):
def _getEndpoint(self, uri):
return TunnelingTCP4ClientEndpoint(
self._reactor, uri.host, uri.port, self._proxyConf,
self._contextFactory, self._endpointFactory._connectTimeout,
self._endpointFactory._bindAddress)
else:
def _getEndpoint(self, scheme, host, port):
return TunnelingTCP4ClientEndpoint(
self._reactor, host, port, self._proxyConf,
self._contextFactory, self._connectTimeout,
self._bindAddress)



class ScrapyAgent(object):
Expand Down

0 comments on commit 540b9bc

Please sign in to comment.