Skip to content

Commit

Permalink
convert tuple to BasicAuth during __init__
Browse files Browse the repository at this point in the history
save some CPU as conversion is only done at startup
  • Loading branch information
kf@quenpc committed Mar 22, 2024
1 parent cbe3c9c commit f0cadaa
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pypeman/contrib/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ def __init__(self, url, *args, method=None, headers=None, auth=None,
self.method = method
self.headers = headers
self.cookies = cookies
if isinstance(auth, tuple):
auth = aiohttp.BasicAuth(*auth)
self.auth = auth
self.verify = verify
self.params = params
Expand Down Expand Up @@ -295,10 +297,7 @@ async def handle_request(self, msg):
else:
get_params.append((key, param))

if isinstance(self.auth, tuple):
basic_auth = aiohttp.BasicAuth(self.auth[0], self.auth[1])
else:
basic_auth = self.auth
basic_auth = self.auth

data = None
if method.lower() in ['put', 'post', 'patch']:
Expand Down

0 comments on commit f0cadaa

Please sign in to comment.