summaryrefslogtreecommitdiff
path: root/searx/search
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-09-28 15:26:34 +0200
committerAlexandre Flament <alex@al-f.net>2021-09-28 19:28:12 +0200
commit29893cf816ab7dccaa68697d5600326b82606972 (patch)
treef99c4d26740560e9e20ac693e6a9588afc720ab4 /searx/search
parent2eab89b4ca12a404390690210f885664fa26c173 (diff)
[fix] searx.network.stream: fix memory leak
Diffstat (limited to 'searx/search')
-rw-r--r--searx/search/checker/impl.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/searx/search/checker/impl.py b/searx/search/checker/impl.py
index 990fd1f6..626aa8ce 100644
--- a/searx/search/checker/impl.py
+++ b/searx/search/checker/impl.py
@@ -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