Skip to content

Ignore Content-Range size for content-encoded HTTP responses - #2518

Merged
martindurant merged 1 commit into
fsspec:masterfrom
shashank11yadav:fix/http-info-content-range-encoding
Nov 30, 2026
Merged

martindurant merged 1 commit into
fsspec:masterfrom
shashank11yadav:fix/http-info-content-range-encoding

Conversation

@shashank11yadav

@shashank11yadav shashank11yadav commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2517

What changed:

  • HTTPFileSystem async _file_info (fsspec/implementations/http.py) checks Content-Encoding before it reads the size from either Content-Length or Content-Range. Before, only Content-Length was gated, so a gzip response with a Content-Range header and no Content-Length reported the compressed total as size.
  • The sync implementation already gates both headers, so it is unchanged.
  • Added test_file_info_content_range_with_encoding in fsspec/implementations/tests/test_http.py, parametrized over no encoding and gzip.
  • Added a changelog entry under Dev > Fixes.

Why:
A size taken from a compressed response does not match the decoded body.

How it was tested:

  • pytest fsspec/implementations/tests/test_http.py fsspec/implementations/tests/test_http_sync.py: passed (238 tests).
  • pytest fsspec/implementations/tests/test_http.py -k test_file_info_content_range_with_encoding -v: both cases passed.
  • Without the fix, the gzip case fails (size is 5, expected None). The no-encoding case passes.
  • ruff check ., ruff format --check . and codespell: passed.
  • Not run: pre-commit run --all-files. The commands above are the closest whole-repo checks that could run.

The async HTTP info call already ignored Content-Length when the response
carried a Content-Encoding, but still took the size from Content-Range. That
reported the compressed length as the file size. Apply the same encoding check
to both headers, as the sync implementation does.
@shashank11yadav
shashank11yadav force-pushed the fix/http-info-content-range-encoding branch from 65293a5 to dfebc5d Compare November 27, 2026 00:47
@martindurant
martindurant merged commit 601d622 into fsspec:master Nov 30, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTPFileSystem.info reports the compressed Content-Range total as size for Content-Encoding responses

2 participants