Revision: 6860 Author: russblau Date: 2009-05-08 18:54:53 +0000 (Fri, 08 May 2009)
Log Message: ----------- Fix SSL connection for sites that use non-standard paths
Modified Paths: -------------- branches/rewrite/pywikibot/comms/http.py branches/rewrite/pywikibot/families/commons_family.py branches/rewrite/pywikibot/families/incubator_family.py branches/rewrite/pywikibot/families/mediawiki_family.py branches/rewrite/pywikibot/families/meta_family.py branches/rewrite/pywikibot/families/species_family.py branches/rewrite/pywikibot/family.py
Modified: branches/rewrite/pywikibot/comms/http.py =================================================================== --- branches/rewrite/pywikibot/comms/http.py 2009-05-08 18:37:38 UTC (rev 6859) +++ branches/rewrite/pywikibot/comms/http.py 2009-05-08 18:54:53 UTC (rev 6860) @@ -93,15 +93,16 @@ if ssl: proto = "https" host = site.ssl_hostname() + uri = site.ssl_pathprefix() + uri else: - proto = "http" + proto = site.protocol() host = site.hostname() - full_uri = "%(proto)s://%(host)s%(uri)s" % locals() - + baseuri = urlparse.urljoin("%(proto)s://%(host)s" % locals(), uri) + # set default user-agent string kwargs.setdefault("headers", {}) kwargs["headers"].setdefault("user-agent", useragent) - request = threadedhttp.HttpRequest(full_uri, *args, **kwargs) + request = threadedhttp.HttpRequest(baseuri, *args, **kwargs) http_queue.put(request) request.lock.acquire()
Modified: branches/rewrite/pywikibot/families/commons_family.py =================================================================== --- branches/rewrite/pywikibot/families/commons_family.py 2009-05-08 18:37:38 UTC (rev 6859) +++ branches/rewrite/pywikibot/families/commons_family.py 2009-05-08 18:54:53 UTC (rev 6860) @@ -43,3 +43,7 @@
def shared_image_repository(self, code): return ('commons', 'commons') + + def ssl_pathprefix(self, code): + return "/wikipedia/commons" +
Modified: branches/rewrite/pywikibot/families/incubator_family.py =================================================================== --- branches/rewrite/pywikibot/families/incubator_family.py 2009-05-08 18:37:38 UTC (rev 6859) +++ branches/rewrite/pywikibot/families/incubator_family.py 2009-05-08 18:54:53 UTC (rev 6860) @@ -19,3 +19,7 @@
def shared_image_repository(self, code): return ('commons', 'commons') + + def ssl_pathprefix(self, code): + return "/wikipedia/incubator" +
Modified: branches/rewrite/pywikibot/families/mediawiki_family.py =================================================================== --- branches/rewrite/pywikibot/families/mediawiki_family.py 2009-05-08 18:37:38 UTC (rev 6859) +++ branches/rewrite/pywikibot/families/mediawiki_family.py 2009-05-08 18:54:53 UTC (rev 6860) @@ -21,3 +21,6 @@
def shared_image_repository(self, code): return ('commons', 'commons') + + def ssl_pathprefix(self, code): + return "/wikipedia/mediawiki"
Modified: branches/rewrite/pywikibot/families/meta_family.py =================================================================== --- branches/rewrite/pywikibot/families/meta_family.py 2009-05-08 18:37:38 UTC (rev 6859) +++ branches/rewrite/pywikibot/families/meta_family.py 2009-05-08 18:54:53 UTC (rev 6860) @@ -20,3 +20,6 @@
def shared_image_repository(self, code): return ('commons', 'commons') + + def ssl_pathprefix(self, code): + return "/wikipedia/meta"
Modified: branches/rewrite/pywikibot/families/species_family.py =================================================================== --- branches/rewrite/pywikibot/families/species_family.py 2009-05-08 18:37:38 UTC (rev 6859) +++ branches/rewrite/pywikibot/families/species_family.py 2009-05-08 18:54:53 UTC (rev 6860) @@ -20,3 +20,6 @@
def shared_image_repository(self, code): return ('commons', 'commons') + + def ssl_pathprefix(self, code): + return "/wikipedia/species"
Modified: branches/rewrite/pywikibot/family.py =================================================================== --- branches/rewrite/pywikibot/family.py 2009-05-08 18:37:38 UTC (rev 6859) +++ branches/rewrite/pywikibot/family.py 2009-05-08 18:54:53 UTC (rev 6860) @@ -809,7 +809,7 @@
def ssl_hostname(self, code): """The hostname to use for SSL connections.""" - return "secure.wikimedia.org/%s/%s" % (self.name, code) + return "secure.wikimedia.org"
def scriptpath(self, code): """The prefix used to locate scripts on this wiki. @@ -825,6 +825,10 @@ """ return '/w'
+ def ssl_pathprefix(self, code): + """The path prefix for secure.wikimedia.org access.""" + return "/%s/%s" % (self.name, code) + def path(self, code): return '%s/index.php' % self.scriptpath(code)
pywikipedia-svn@lists.wikimedia.org