From cac0d1c3942db9fddefadb4d5d8d82cdee0b09bf Mon Sep 17 00:00:00 2001 From: umkay Date: Thu, 3 Nov 2016 17:05:50 -0700 Subject: [PATCH] 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. --- zulip/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zulip/__init__.py b/zulip/__init__.py index 6aa118f..bacfcf1 100644 --- a/zulip/__init__.py +++ b/zulip/__init__.py @@ -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("/")