Scrapy, a fast high-level web crawling & scraping framework for Python.
remove ssl from optional_features to simplify code, as it is now required. also deprecate optional_features set
Pablo Hoffman9968f99e06e3
diff --git a/scrapy/__init__.py b/scrapy/__init__.pyindex 762106c59..a02f1644c 100644--- a/scrapy/__init__.py+++ b/scrapy/__init__.py@@ -17,15 +17,11 @@ warnings.filterwarnings('ignore', category=DeprecationWarning, module='twisted')# monkey patches to fix external library issuesfrom scrapy.xlib import urlparse_monkeypatches-# optional_features is a set containing Scrapy optional features+# WARNING: optional_features set is deprecated and will be removed soon. Do not use.optional_features = set()-try:- import OpenSSL-except ImportError:- pass-else:- optional_features.add('ssl')+# TODO: backwards compatibility, remove for Scrapy 0.20+optional_features.add('ssl')try:import botodiff --git a/scrapy/core/downloader/handlers/http.py b/scrapy/core/downloader/handlers/http.pyindex f566d090b..7d91f1fb7 100644--- a/scrapy/core/downloader/handlers/http.py+++ b/scrapy/core/downloader/handlers/http.py@@ -2,11 +2,7 @@from twisted.internet import reactor-from scrapy.exceptions import NotSupportedfrom scrapy.utils.misc import load_object-from scrapy import optional_features--ssl_supported = 'ssl' in optional_featuresclass HttpDownloadHandler(object):@@ -23,9 +19,7 @@ class HttpDownloadHandler(object):def _connect(self, factory):host, port = factory.host, factory.portif factory.scheme == 'https':- if ssl_supported:- return reactor.connectSSL(host, port, factory, \- self.ClientContextFactory())- raise NotSupported("HTTPS not supported: install pyopenssl library")+ return reactor.connectSSL(host, port, factory, \+ self.ClientContextFactory())else:return reactor.connectTCP(host, port, factory)diff --git a/scrapy/core/downloader/webclient.py b/scrapy/core/downloader/webclient.pyindex 142b555b9..a7a6140f9 100644--- a/scrapy/core/downloader/webclient.py+++ b/scrapy/core/downloader/webclient.py@@ -1,14 +1,15 @@from time import timefrom urlparse import urlparse, urlunparse, urldefrag+from twisted.internet.ssl import ClientContextFactoryfrom twisted.web.client import HTTPClientFactoryfrom twisted.web.http import HTTPClientfrom twisted.internet import defer+from OpenSSL import SSLfrom scrapy.http import Headersfrom scrapy.utils.httpobj import urlparse_cachedfrom scrapy.responsetypes import responsetypes-from scrapy import optional_featuresdef _parsed_url_args(parsed):@@ -138,13 +139,6 @@ class ScrapyHTTPClientFactory(HTTPClientFactory):-if 'ssl' in optional_features:- from twisted.internet.ssl import ClientContextFactory- from OpenSSL import SSL-else:- ClientContextFactory = object--class ScrapyClientContextFactory(ClientContextFactory):"A SSL context factory which is more permissive against SSL bugs."# see https://github.com/scrapy/scrapy/issues/82