fix: Avoid exception when there are no cookies

pull/997/head
Raphaël Vinot 2024-11-19 16:25:58 +01:00
parent 5603f88cbc
commit 1db6135e79
1 changed files with 3 additions and 1 deletions

View File

@ -462,7 +462,9 @@ class CaptureInfo(Resource): # type: ignore[misc]
params={'capture_uuid': 'The UUID of the capture'}) params={'capture_uuid': 'The UUID of the capture'})
class CaptureCookies(Resource): # type: ignore[misc] class CaptureCookies(Resource): # type: ignore[misc]
def get(self, capture_uuid: str) -> dict[str, Any]: def get(self, capture_uuid: str) -> dict[str, Any]:
return json.loads(lookyloo.get_cookies(capture_uuid).read()) if cookies := lookyloo.get_cookies(capture_uuid).read():
return json.loads(cookies)
return {}
@api.route('/json/<string:capture_uuid>/report') @api.route('/json/<string:capture_uuid>/report')