|
19 | 19 | from scrapy.responsetypes import responsetypes
|
20 | 20 | from scrapy.core.downloader.webclient import _parse
|
21 | 21 | from scrapy.utils.misc import load_object
|
| 22 | +from scrapy import twisted_version |
22 | 23 |
|
23 | 24 |
|
24 | 25 | class HTTP11DownloadHandler(object):
|
@@ -137,10 +138,19 @@ def __init__(self, reactor, proxyConf, contextFactory=None,
|
137 | 138 | self._proxyConf = proxyConf
|
138 | 139 | self._contextFactory = contextFactory
|
139 | 140 |
|
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 | + |
144 | 154 |
|
145 | 155 |
|
146 | 156 | class ScrapyAgent(object):
|
|
0 commit comments