From f0d74f971a48546aaafbbd79fe9dd5295dc63758 Mon Sep 17 00:00:00 2001 From: Janez K Date: Sat, 12 Apr 2014 09:18:43 +0200 Subject: [PATCH 1/2] also return headers with the content so that x-rate-limit-remaining can be accessed --- twython/api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/twython/api.py b/twython/api.py index 1d23a35..aa75ddb 100644 --- a/twython/api.py +++ b/twython/api.py @@ -182,6 +182,7 @@ class Twython(EndpointsMixin, object): except ValueError: raise TwythonError('Response was not valid JSON. Unable to decode.') + content['headers']=dict(response.headers) return content def _get_error_message(self, response): From 80fa133255d31ef3315f5c71d4c984fcb8460799 Mon Sep 17 00:00:00 2001 From: Janez K Date: Mon, 14 Apr 2014 10:35:22 +0200 Subject: [PATCH 2/2] fixed test so that headers don't get in the way --- tests/test_core.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_core.py b/tests/test_core.py index 5b8a374..57bc488 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -206,6 +206,9 @@ class TwythonAPITestCase(unittest.TestCase): self.register_response(responses.GET, url, body='{"id": 210462857140252672}') data = self.api.request(endpoint, params={'id': 210462857140252672}) + + if 'headers' in data: + del data['headers'] self.assertEqual({'id': 210462857140252672}, data)