Compare commits
No commits in common. "f5b68439686eec7f5a904574fa9cacf54cec3015" and "e0ad9ee248affeea9bbe3535be07900264b9627e" have entirely different histories.
f5b6843968
...
e0ad9ee248
1 changed files with 2 additions and 4 deletions
|
|
@ -64,18 +64,16 @@ def fetch_url(base: str, url: str) -> str | None:
|
|||
content_length = response.headers.get("Content-Length")
|
||||
if content_length is not None:
|
||||
try:
|
||||
if int(content_length) > 2_500_000:
|
||||
if int(content_length) > 500_000:
|
||||
return None
|
||||
except ValueError:
|
||||
pass # Invalid Content-Length format, proceed to stream
|
||||
content = b""
|
||||
for chunk in response.iter_content(chunk_size=1024):
|
||||
content += chunk
|
||||
if len(content) > 2_500_000:
|
||||
if len(content) > 500_000:
|
||||
return None
|
||||
content_type = response.headers.get("Content-Type", "")
|
||||
if content_type == "":
|
||||
return None
|
||||
return encode_data_uri(content, content_type)
|
||||
except requests.exceptions.RequestException:
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue