Skip to content

Commit

Permalink
headers update
Browse files Browse the repository at this point in the history
  • Loading branch information
joente committed Dec 25, 2022
1 parent 522c7bf commit 92bd30b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions pylibagent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def __init__(self, key: str, version: str):
exit(1)

self._loop: Optional[asyncio.AbstractEventLoop] = None
self._get_headers = {'Authorization': f'Bearer {token}'}
self._headers = {'Authorization': f'Bearer {token}'}
self._json_headers = {'Content-Type': 'application/json'}
self._json_headers.update(self._get_headers)
self._json_headers.update(self._headers)

self.asset_id: Optional[int] = None
self.api_uri: str = os.getenv('API_URI', 'https://api.infrasonar.com')
Expand All @@ -93,7 +93,7 @@ async def announce(self, asset_name: Optional[str] = None,
return

url = _join(self.api_uri, f'asset/{self.asset_id}')
async with ClientSession(headers=self._get_headers) as session:
async with ClientSession(headers=self._headers) as session:
async with session.get(
url,
params={'field': 'name'},
Expand Down Expand Up @@ -235,7 +235,7 @@ async def _check_loop(self, check):
async def _create_asset(self, asset_name: Optional[str] = None,
asset_kind: Optional[str] = None) -> int:
url = _join(self.api_uri, 'container/id')
async with ClientSession(headers=self._get_headers) as session:
async with ClientSession(headers=self._headers) as session:
async with session.get(url, ssl=self.verify_ssl) as r:
if r.status != 200:
msg = await r.text()
Expand All @@ -258,7 +258,7 @@ async def _create_asset(self, asset_name: Optional[str] = None,

try:
url = _join(self.api_uri, f'asset/{asset_id}/collector/{self.key}')
async with ClientSession(headers=self._json_headers) as session:
async with ClientSession(headers=self._headers) as session:
async with session.post(url, ssl=self.verify_ssl) as r:
if r.status != 204:
msg = await r.text()
Expand Down
2 changes: 1 addition & 1 deletion pylibagent/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.8'
__version__ = '0.1.9'

0 comments on commit 92bd30b

Please sign in to comment.