From 70a78d7d780f503e404be1a9901aabc015a92258 Mon Sep 17 00:00:00 2001 From: Harmon Date: Thu, 28 Jan 2021 11:42:03 -0600 Subject: [PATCH] Stop overriding default requests Session headers in APIMethod Pass custom headers to Session.request instead --- tweepy/binder.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tweepy/binder.py b/tweepy/binder.py index 68cc66d..2cfde89 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -54,7 +54,7 @@ def bind_api(**config): api.wait_on_rate_limit_notify) self.return_cursors = kwargs.pop('return_cursors', False) self.parser = kwargs.pop('parser', api.parser) - self.session.headers = kwargs.pop('headers', {}) + self.headers = kwargs.pop('headers', {}) self.build_parameters(args, kwargs) # Pick correct URL root to use @@ -75,7 +75,7 @@ def bind_api(**config): # or older where Host is set including the 443 port. # This causes Twitter to issue 301 redirect. # See Issue https://github.com/tweepy/tweepy/issues/12 - self.session.headers['Host'] = self.host + self.headers['Host'] = self.host # Monitoring rate limits self._remaining_calls = None self._reset_time = None @@ -161,12 +161,13 @@ def bind_api(**config): # Request compression if configured if self.api.compression: - self.session.headers['Accept-encoding'] = 'gzip' + self.headers['Accept-encoding'] = 'gzip' # Execute request try: resp = self.session.request(self.method, full_url, + headers=self.headers, data=self.post_data, json=self.json_payload, timeout=self.api.timeout, -- 2.25.1