Skip to content

Commit 540b9bc

Browse files
curitadangra
authored andcommitted
Support new _getEndpoint Agent signatures on Twisted 15.0.0
1 parent b4c454b commit 540b9bc

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

scrapy/core/downloader/handlers/http11.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from scrapy.responsetypes import responsetypes
2020
from scrapy.core.downloader.webclient import _parse
2121
from scrapy.utils.misc import load_object
22+
from scrapy import twisted_version
2223

2324

2425
class HTTP11DownloadHandler(object):
@@ -137,10 +138,19 @@ def __init__(self, reactor, proxyConf, contextFactory=None,
137138
self._proxyConf = proxyConf
138139
self._contextFactory = contextFactory
139140

140-
def _getEndpoint(self, scheme, host, port):
141-
return TunnelingTCP4ClientEndpoint(self._reactor, host, port,
142-
self._proxyConf, self._contextFactory, self._connectTimeout,
143-
self._bindAddress)
141+
if twisted_version >= (15, 0, 0):
142+
def _getEndpoint(self, uri):
143+
return TunnelingTCP4ClientEndpoint(
144+
self._reactor, uri.host, uri.port, self._proxyConf,
145+
self._contextFactory, self._endpointFactory._connectTimeout,
146+
self._endpointFactory._bindAddress)
147+
else:
148+
def _getEndpoint(self, scheme, host, port):
149+
return TunnelingTCP4ClientEndpoint(
150+
self._reactor, host, port, self._proxyConf,
151+
self._contextFactory, self._connectTimeout,
152+
self._bindAddress)
153+
144154

145155

146156
class ScrapyAgent(object):

0 commit comments

Comments
 (0)