Skip to content

Commit

Permalink
If .USERAGENT file is empty then don't set it in
Browse files Browse the repository at this point in the history
header
  • Loading branch information
ehendrix23 committed Feb 24, 2021
1 parent fcd5ac6 commit 07d3ace
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pymyq/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ def __init__(self, websession: ClientSession = None) -> None:
self._last_useragent_update = None

async def _get_useragent(self) -> None:
"""Retrieve a user agent to use in headers.
Returns:
str: user agent
"""
"""Retrieve a user agent to use in headers."""

# Only see to retrieve a user agent if currently we do not have one,
# we do not have an datetime on when we last retrieved one,
Expand Down Expand Up @@ -72,6 +68,7 @@ async def _get_useragent(self) -> None:
str(exc),
)

useragent = useragent.strip()
# Check if value for useragent is to create a random user agent.
useragent_list = useragent.split(":")
if useragent_list[0] == "#RANDOM":
Expand Down Expand Up @@ -118,7 +115,8 @@ async def _send_request(
if self._useragent is None:
await self._get_useragent()

headers.update({"User-Agent": self._useragent})
if self._useragent is not None and self._useragent != "":
headers.update({"User-Agent": self._useragent})

if attempt != 0:
wait_for = min(2 ** attempt, 5)
Expand Down

0 comments on commit 07d3ace

Please sign in to comment.