Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify Content-Encoding when querying Content-Length #1320

Merged
merged 1 commit into from
Aug 10, 2023

Conversation

nkemnitz
Copy link
Contributor

Fixes #1319.

# 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":
info["size"] = int(r.headers["Content-Length"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise is remains None and can only be streamed? That is probably right, but could use some tests to make sure we are getting the right behaviour.

@nkemnitz
Copy link
Contributor Author

nkemnitz commented Aug 9, 2023

Added a test that will fail on the current main branch and succeed with this PR.

)
url = server + "/index/realfile"

with h.open(url, "rb") as f:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f is a streaming type file here, with None for the size? Should probably assert that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, not super familiar with fsspec, yet - Only tried to mimic the test above this one. Added assertions for type and size, now.

@martindurant martindurant merged commit 45a6aec into fsspec:master Aug 10, 2023
11 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.

Truncated response when downloading "Content-Type: gzip" file
2 participants