Add proxy support
authorAaron Hill <aa1ronham@gmail.com>
Tue, 29 Apr 2014 22:00:17 +0000 (18:00 -0400)
committerAaron Hill <aa1ronham@gmail.com>
Tue, 29 Apr 2014 22:00:17 +0000 (18:00 -0400)
tweepy/api.py
tweepy/binder.py

index 0e606ec670089f933d902ca372b6ff03c0380859..3d76646fc6dfa2f723a13f09380d04184e9e6e8d 100644 (file)
@@ -19,7 +19,7 @@ class API(object):
              cache=None, api_root='/1.1', search_root='',
             retry_count=0, retry_delay=0, retry_errors=None, timeout=60,
             parser=None, compression=False, wait_on_rate_limit=False,
-            wait_on_rate_limit_notify=False):
+            wait_on_rate_limit_notify=False, proxy=None):
         self.auth = auth_handler
         self.host = host
         self.search_host = search_host
@@ -34,6 +34,9 @@ class API(object):
         self.wait_on_rate_limit = wait_on_rate_limit
         self.wait_on_rate_limit_notify = wait_on_rate_limit_notify
         self.parser = parser or ModelParser()
+        self.proxy = {}
+        if proxy:
+            self.proxy['https'] = proxy
 
     """ statuses/home_timeline """
     home_timeline = bind_api(
index c1c58ea781b883b0568d49f7020802c2098e688a..4997cf631a2c7bee57076581ba9d608fa94e4523 100644 (file)
@@ -154,7 +154,7 @@ def bind_api(**config):
                 try:
                     resp = self.session.request(self.method, full_url,
                             data=self.post_data, timeout=self.api.timeout,
-                            auth=auth)
+                            auth=auth, proxies=self.api.proxy)
                 except Exception, e:
                     raise TweepError('Failed to send request: %s' % e)
                 rem_calls = resp.headers.get('x-rate-limit-remaining')