jenkins-bot has submitted this change and it was merged.
Change subject: Extended comms/http.py so that it can also be used for non wiki site requests ......................................................................
Extended comms/http.py so that it can also be used for non wiki site requests
Original-Change-Id: Ib7e8a545334d11b73e93a740b39690520ef209f6 Change-Id: Ifc9e29ce43cce63eff305b956da40b4e41f273f9 --- M pywikibot/comms/http.py 1 file changed, 14 insertions(+), 7 deletions(-)
Approvals: Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py index 1dee9ec..a4ad829 100644 --- a/pywikibot/comms/http.py +++ b/pywikibot/comms/http.py @@ -95,20 +95,27 @@ All parameters not listed below are the same as L{httplib2.Http.request}, but the uri is relative
+ If the site argument is None the uri has to be absolute and is + taken. In this case ssl is ignored. Used for requests to non wiki + pages. + @param site: The Site to connect to @param uri: the URI to retrieve (relative to the site's scriptpath) @param ssl: Use https connection @return: The received data (a unicode string).
""" - if ssl: - proto = "https" - host = site.ssl_hostname() - uri = site.ssl_pathprefix() + uri + if site: + if ssl: + proto = "https" + host = site.ssl_hostname() + uri = site.ssl_pathprefix() + uri + else: + proto = site.protocol() + host = site.hostname() + baseuri = urlparse.urljoin("%(proto)s://%(host)s" % locals(), uri) else: - proto = site.protocol() - host = site.hostname() - baseuri = urlparse.urljoin("%(proto)s://%(host)s" % locals(), uri) + baseuri = uri
# set default user-agent string kwargs.setdefault("headers", {})