Repository navigation
Ignore Content-Range size for content-encoded HTTP responses - #2518
Merged
martindurant merged 1 commit intoNov 30, 2026
Merged
martindurant merged 1 commit into
martindurant merged 1 commit into
Conversation
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
force-pushed
the
fix/http-info-content-range-encoding
branch
from
November 27, 2026 00:47
65293a5 to
dfebc5d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2517
What changed:
HTTPFileSystemasync_file_info(fsspec/implementations/http.py) checksContent-Encodingbefore it reads the size from eitherContent-LengthorContent-Range. Before, onlyContent-Lengthwas gated, so a gzip response with aContent-Rangeheader and noContent-Lengthreported the compressed total assize.test_file_info_content_range_with_encodingin fsspec/implementations/tests/test_http.py, parametrized over no encoding andgzip.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.gzipcase fails (size is 5, expected None). The no-encoding case passes.ruff check .,ruff format --check .andcodespell: passed.pre-commit run --all-files. The commands above are the closest whole-repo checks that could run.