Fix a bug that would result in a 301 redirect with python 2.5 or older using secure...
authorJoshua Roesslein <jroesslein@gmail.com>
Sun, 31 Jan 2010 03:31:20 +0000 (21:31 -0600)
committerJoshua Roesslein <jroesslein@gmail.com>
Sun, 31 Jan 2010 03:31:20 +0000 (21:31 -0600)
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

index 1593600783e0348b7335aaf08009759f7a675d7b..f940f669ac4f2c64733ec721c4e9ab6a2047f5d7 100644 (file)
@@ -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):