From 02995d7e886fa1b01a1bb0ed0b759d75021835db Mon Sep 17 00:00:00 2001 From: Domenico Nappo Date: Mon, 19 Nov 2018 14:37:31 +0100 Subject: [PATCH] Adding response.headers to on_error method in twython.streaming.api #503 --- twython/streaming/api.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/twython/streaming/api.py b/twython/streaming/api.py index 0195f38..dd4ae89 100644 --- a/twython/streaming/api.py +++ b/twython/streaming/api.py @@ -125,7 +125,7 @@ class TwythonStreamer(object): self.on_timeout() else: if response.status_code != 200: - self.on_error(response.status_code, response.content) + self.on_error(response.status_code, response.content, response.headers) if self.retry_count and \ (self.retry_count - retry_counter) > 0: @@ -178,7 +178,7 @@ class TwythonStreamer(object): """ return True - def on_error(self, status_code, data): # pragma: no cover + def on_error(self, status_code, data, headers=None): # pragma: no cover """Called when stream returns non-200 status code Feel free to override this to handle your streaming data how you @@ -189,6 +189,9 @@ class TwythonStreamer(object): :param data: Error message sent from stream :type data: dict + + :param headers: Response headers sent from the stream (i.e. Retry-After) + :type headers: dict """ return