From 45d5a4ac44aac2b0023239bcc5c1100ab4a6fcb1 Mon Sep 17 00:00:00 2001 From: Joshua Roesslein Date: Sat, 30 Jan 2010 21:31:20 -0600 Subject: [PATCH] Fix a bug that would result in a 301 redirect with python 2.5 or older using secure HTTPS. These versions of python include the port number in the host header. Twitter will send us a 301 when a host is provided in this manner. To avoid this redirect this patch manually sets the host w/o the port number. Fixes issue #12 --- tweepy/binder.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tweepy/binder.py b/tweepy/binder.py index 1593600..f940f66 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -57,6 +57,12 @@ def bind_api(**config): else: self.host = api.host + # Manually set Host header to fix an issue in python 2.5 + # or older where Host is set including the 443 port. + # This causes Twitter to issue 301 redirect. + # See Issue http://github.com/joshthecoder/tweepy/issues/#issue/12 + self.headers['Host'] = self.host + def build_parameters(self, args, kargs): self.parameters = {} for idx, arg in enumerate(args): -- 2.25.1