diff --git a/scrapy/settings/default_settings.py b/scrapy/settings/default_settings.py index 2eb15f96c..e18362b13 100644 --- a/scrapy/settings/default_settings.py +++ b/scrapy/settings/default_settings.py @@ -53,8 +53,8 @@ DOWNLOAD_DELAY = 0 DOWNLOAD_HANDLERS = {} DOWNLOAD_HANDLERS_BASE = { 'file': 'scrapy.core.downloader.handlers.file.FileDownloadHandler', - 'http': 'scrapy.core.downloader.handlers.http11.Http11DownloadHandler', - 'https': 'scrapy.core.downloader.handlers.http11.Http11DownloadHandler', + 'http': 'scrapy.core.downloader.handlers.http.HttpDownloadHandler', + 'https': 'scrapy.core.downloader.handlers.http.HttpDownloadHandler', 's3': 'scrapy.core.downloader.handlers.s3.S3DownloadHandler', } diff --git a/scrapy/tests/test_downloader_handlers.py b/scrapy/tests/test_downloader_handlers.py index 2e2497b08..1307f57ad 100644 --- a/scrapy/tests/test_downloader_handlers.py +++ b/scrapy/tests/test_downloader_handlers.py @@ -1,4 +1,5 @@ import os +import twisted from twisted.trial import unittest from twisted.protocols.policies import WrappingFactory @@ -143,6 +144,9 @@ class Http11TestCase(HttpTestCase): """HTTP 1.1 test case""" download_handler_cls = Http11DownloadHandler + if twisted.__version__.split('.') < (11, 1, 0): + skip = 'HTTP1.1 not supported in twisted < 11.1.0' + class UriResource(resource.Resource): """Return the full uri that was requested""" @@ -198,6 +202,9 @@ class HttpProxyTestCase(unittest.TestCase): class Http11ProxyTestCase(HttpProxyTestCase): download_handler_cls = Http11DownloadHandler + if twisted.__version__.split('.') < (11, 1, 0): + skip = 'HTTP1.1 not supported in twisted < 11.1.0' + class HttpDownloadHandlerMock(object): def __init__(self, settings): diff --git a/scrapy/xlib/tx/__init__.py b/scrapy/xlib/tx/__init__.py index 9f731c5b6..e184a6735 100644 --- a/scrapy/xlib/tx/__init__.py +++ b/scrapy/xlib/tx/__init__.py @@ -1,9 +1,19 @@ import twisted -if twisted.__version__.split('.') < (13, 0, 1): - from . import client, endpoints -else: +txver = twisted.__version__.split('.') +if txver > (13, 0, 0): from twisted.web import client from twisted.internet import endpoints +if txver >= (11, 1, 0): + from . import client, endpoints +else: + from scrapy.exceptions import NotSupported + class _Mocked(object): + def __init__(self, *args, **kw): + raise NotSupported('HTTP1.1 not supported') + class _Mock(object): + def __getattr__(self, name): + return _Mocked + client = endpoints = _Mock() Agent = client.Agent