Skip to content

Commit

Permalink
Misc improv fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CastagnaIT committed Jun 17, 2021
1 parent 5bf0865 commit 6486ec9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
3 changes: 2 additions & 1 deletion resources/lib/services/nfsession/msl/msl_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def _post(self, endpoint, request_data):
_endpoint = endpoint
LOG.debug('Executing POST request to {}', _endpoint)
start = time.perf_counter()
response = self.nfsession.session.post(_endpoint, request_data,
response = self.nfsession.session.post(url=_endpoint,
data=request_data,
headers=self.HTTP_HEADERS,
timeout=4)
LOG.debug('Request took {}s', time.perf_counter() - start)
Expand Down
4 changes: 2 additions & 2 deletions resources/lib/services/nfsession/session/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ def login_auth_data(self, data=None, password=None):
'path': cookie['path'],
'path_specified': bool(cookie['path']),
'secure': cookie['secure'],
'expires': cookie.get('expires'),
'expires': cookie['expires'],
'discard': True,
'comment': None,
'comment_url': None,
'rest': cookie.get('rest', {'HttpOnly': None}),
'rest': cookie['rest'],
'rfc2109': False,
}
cookie = Cookie(**kwargs)
Expand Down
13 changes: 6 additions & 7 deletions resources/lib/services/nfsession/session/http_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ class SessionHTTPRequests(SessionBase):
def get(self, endpoint, **kwargs):
"""Execute a GET request to the designated endpoint."""
return self._request_call(
method=self.session.get,
method='GET',
endpoint=endpoint,
**kwargs)

def post(self, endpoint, **kwargs):
"""Execute a POST request to the designated endpoint."""
return self._request_call(
method=self.session.post,
method='POST',
endpoint=endpoint,
**kwargs)

Expand All @@ -56,17 +56,16 @@ def _request(self, method, endpoint, session_refreshed, **kwargs):
retry = 1
while True:
try:
LOG.debug('Executing {verb} request to {url}',
verb='GET' if method == self.session.get else 'POST', url=url)
LOG.debug('Executing {verb} request to {url}', verb=method, url=url)
start = time.perf_counter()
if method == self.session.get:
response = method(
if method == 'GET':
response = self.session.get(
url=url,
headers=headers,
params=params,
timeout=8)
else:
response = method(
response = self.session.post(
url=url,
headers=headers,
params=params,
Expand Down
11 changes: 4 additions & 7 deletions resources/lib/utils/cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,12 @@ def cookie_file_path():

def convert_chrome_cookie(cookie):
"""Convert a cookie from Chrome to a CookieJar format type"""
kwargs = {
return {
'name': cookie['name'],
'value': cookie['value'],
'domain': cookie['domain'],
'path': cookie['path'],
'secure': cookie['secure']
'secure': cookie['secure'],
'expires': int(cookie['expires']) if cookie['expires'] != -1 else None,
'rest': {'HttpOnly': True if cookie['httpOnly'] else None}
}
if cookie['expires'] != -1:
kwargs['expires'] = int(cookie['expires'])
if cookie['httpOnly']:
kwargs['rest'] = {'HttpOnly': True}
return kwargs

0 comments on commit 6486ec9

Please sign in to comment.