Skip to content

Commit 22892dc

Browse files
authored
Allow HTTP size guess when encoding header is missing (#1440)
1 parent 3c247f5 commit 22892dc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fsspec/implementations/http.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,10 @@ async def _file_info(url, session, size_policy="head", **kwargs):
839839
if "Content-Length" in r.headers:
840840
# Some servers may choose to ignore Accept-Encoding and return
841841
# compressed content, in which case the returned size is unreliable.
842-
if r.headers.get("Content-Encoding", "identity") == "identity":
842+
if "Content-Encoding" not in r.headers or r.headers["Content-Encoding"] in [
843+
"identity",
844+
"",
845+
]:
843846
info["size"] = int(r.headers["Content-Length"])
844847
elif "Content-Range" in r.headers:
845848
info["size"] = int(r.headers["Content-Range"].split("/")[1])

0 commit comments

Comments
 (0)