Skip to content

Commit

Permalink
Allow HTTP size guess when encoding header is missing (#1440)
Browse files Browse the repository at this point in the history
  • Loading branch information
martindurant authored Nov 30, 2023
1 parent 3c247f5 commit 22892dc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fsspec/implementations/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,10 @@ async def _file_info(url, session, size_policy="head", **kwargs):
if "Content-Length" in r.headers:
# Some servers may choose to ignore Accept-Encoding and return
# compressed content, in which case the returned size is unreliable.
if r.headers.get("Content-Encoding", "identity") == "identity":
if "Content-Encoding" not in r.headers or r.headers["Content-Encoding"] in [
"identity",
"",
]:
info["size"] = int(r.headers["Content-Length"])
elif "Content-Range" in r.headers:
info["size"] = int(r.headers["Content-Range"].split("/")[1])
Expand Down

0 comments on commit 22892dc

Please sign in to comment.