Update the User-Agent header based on AsyncStream.user_agent
authorHarmon <Harmon758@gmail.com>
Wed, 18 May 2022 14:03:36 +0000 (09:03 -0500)
committerHarmon <Harmon758@gmail.com>
Wed, 18 May 2022 14:04:42 +0000 (09:04 -0500)
Even if AsyncStream.session is already initialized/set

tweepy/asynchronous/streaming.py

index 1932a86cfafaf13ed04cb6bda4448adab90fa74c..3bf172359cd6199ba15f4940e3d353f0c2d7096b 100644 (file)
@@ -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())))