fix: Import gz HAR file from export

pull/888/head
Raphaël Vinot 2024-02-28 01:07:17 +01:00
parent 07351293f8
commit e57268a9ab
1 changed files with 6 additions and 1 deletions

View File

@ -5,6 +5,7 @@ from __future__ import annotations
import base64 import base64
import calendar import calendar
import functools import functools
import gzip
import hashlib import hashlib
import http import http
import json import json
@ -1090,7 +1091,11 @@ def submit_capture() -> str | Response | WerkzeugResponse:
with ZipFile(BytesIO(request.files['full_capture'].stream.read()), 'r') as lookyloo_capture: with ZipFile(BytesIO(request.files['full_capture'].stream.read()), 'r') as lookyloo_capture:
potential_favicons = set() potential_favicons = set()
for filename in lookyloo_capture.namelist(): for filename in lookyloo_capture.namelist():
if filename.endswith('0.har'): if filename.endswith('0.har.gz'):
# new formal
har = json.loads(gzip.decompress(lookyloo_capture.read(filename)))
elif filename.endswith('0.har'):
# old format
har = json.loads(lookyloo_capture.read(filename)) har = json.loads(lookyloo_capture.read(filename))
elif filename.endswith('0.html'): elif filename.endswith('0.html'):
html = lookyloo_capture.read(filename).decode() html = lookyloo_capture.read(filename).decode()