Avoid downloading of too big files
This commit is contained in:
parent
309615cdc7
commit
bd4a9e17eb
@ -110,7 +110,13 @@ def getURLContent(url, timeout=15):
|
||||
|
||||
try:
|
||||
res = conn.getresponse()
|
||||
data = res.read()
|
||||
size = int(res.getheader("Content-Length", 5000))
|
||||
cntype = res.getheader("Content-Type")
|
||||
|
||||
if size > 10000 or cntype[:4] != "text":
|
||||
return None
|
||||
|
||||
data = res.read(size)
|
||||
except http.client.BadStatusLine:
|
||||
return None
|
||||
finally:
|
||||
|
Loading…
x
Reference in New Issue
Block a user