[fix] searx.network.stream: fix memory leak

This commit is contained in:
Alexandre Flament 2021-09-28 15:26:34 +02:00
parent 2eab89b4ca
commit 29893cf816
3 changed files with 42 additions and 17 deletions

View file

@ -85,7 +85,10 @@ def _download_and_check_if_image(image_url: str) -> bool:
})
r = next(stream)
r.close()
is_image = r.headers["content-type"].startswith('image/')
if r.status_code == 200:
is_image = r.headers.get('content-type', '').startswith('image/')
else:
is_image = False
del r
del stream
return is_image