tools/web: allow empty Content-Type
This commit is contained in:
parent
dd285b67d1
commit
0b06261d18
@ -102,13 +102,14 @@ def getURLContent(url, timeout=15):
|
|||||||
size = int(res.getheader("Content-Length", 200000))
|
size = int(res.getheader("Content-Length", 200000))
|
||||||
cntype = res.getheader("Content-Type")
|
cntype = res.getheader("Content-Type")
|
||||||
|
|
||||||
if size > 200000 or (cntype[:4] != "text" and cntype[:4] != "appl"):
|
if size > 200000 or (cntype is not None and cntype[:4] != "text" and cntype[:4] != "appl"):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
data = res.read(size)
|
data = res.read(size)
|
||||||
|
|
||||||
# Decode content
|
# Decode content
|
||||||
charset = "utf-8"
|
charset = "utf-8"
|
||||||
|
if cntype is not None:
|
||||||
lcharset = res.getheader("Content-Type").split(";")
|
lcharset = res.getheader("Content-Type").split(";")
|
||||||
if len(lcharset) > 1:
|
if len(lcharset) > 1:
|
||||||
for c in charset:
|
for c in charset:
|
||||||
|
Loading…
Reference in New Issue
Block a user