From c43a15ed1886b5d3c6fdc5f631d8ca5c5d4a7e24 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. --- api/zulip/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/zulip/__init__.py b/api/zulip/__init__.py index 6aa118fbeb..bacfcf1ca7 100644 --- a/api/zulip/__init__.py +++ b/api/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("/")