saper has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/98396


Change subject: Don't use SSL if not available
......................................................................

Don't use SSL if not available

There might still be some installations
with httplib without HTTPS for some reason.

Don't try to use https on those (in case
of Wikipedia, the use of SSL was actually
forced).

Change-Id: I5809364eb02d8669fc2b62734ca1e3e48824b129
---
M family.py
1 file changed, 13 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/compat 
refs/changes/96/98396/1

diff --git a/family.py b/family.py
index 30e2bed..c691a9f 100644
--- a/family.py
+++ b/family.py
@@ -4209,12 +4209,20 @@
         return self.namespace(code, 14, all=True)
 
     # Methods
+    def ssl_available(self):
+        """Check if SSL support is available"""
+        import httplib
+        return hasattr(httplib, "HTTPS")
+
     def protocol(self, code):
         """
         Can be overridden to return 'https'. Other protocols are not supported.
 
         """
-        return 'http%s' % ('', 's')[config.SSL_connection]
+        if self.ssl_available():
+             return 'http%s' % ('', 's')[config.SSL_connection]
+        else:
+             return 'http'
 
     def hostname(self, code):
         """The hostname to use for standard http connections."""
@@ -4867,4 +4875,7 @@
         return ('commons', 'commons')
 
     def protocol(self, code):
-        return 'https'
+        if self.ssl_available():
+            return 'https'
+        else:
+            return 'http'

-- 
To view, visit https://gerrit.wikimedia.org/r/98396
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5809364eb02d8669fc2b62734ca1e3e48824b129
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: saper <sa...@saper.info>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to