api: Add default protocol for localhost.

Add default "http://" to site argument locally if it is not specified
in an api call.

This fixes a problem where if you didn't manually specify `http://`
when connecting to a development server, the API bindings would hang
trying to connect using HTTPS.
This commit is contained in:
umkay 2016-11-03 17:05:50 -07:00 committed by Tim Abbott
parent 4cdc59a3e4
commit cac0d1c394

View file

@ -213,7 +213,9 @@ class Client(object):
self.email = email
self.verbose = verbose
if site is not None:
if not site.startswith("http"):
if site.startswith("localhost"):
site = "http://" + site
elif not site.startswith("http"):
site = "https://" + site
# Remove trailing "/"s from site to simplify the below logic for adding "/api"
site = site.rstrip("/")