From 096a62c737218c4b51682c1127ab2a876547ad73 Mon Sep 17 00:00:00 2001 From: Harmon Date: Wed, 18 May 2022 09:03:36 -0500 Subject: [PATCH] Update the User-Agent header based on AsyncStream.user_agent Even if AsyncStream.session is already initialized/set --- tweepy/asynchronous/streaming.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tweepy/asynchronous/streaming.py b/tweepy/asynchronous/streaming.py index 1932a86..3bf1723 100644 --- a/tweepy/asynchronous/streaming.py +++ b/tweepy/asynchronous/streaming.py @@ -82,9 +82,9 @@ class AsyncStream: if self.session is None or self.session.closed: self.session = aiohttp.ClientSession( - headers={"User-Agent": self.user_agent}, timeout=aiohttp.ClientTimeout(sock_read=stall_timeout) ) + self.session.headers["User-Agent"] = self.user_agent url = f"https://stream.twitter.com/1.1/{endpoint}.json" url = str(URL(url).with_query(sorted(params.items()))) -- 2.25.1