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

Potential for wrong download file size? #5

Open
CiaranG opened this issue Nov 12, 2012 · 1 comment
Open

Potential for wrong download file size? #5

CiaranG opened this issue Nov 12, 2012 · 1 comment

Comments

@CiaranG
Copy link
Contributor

CiaranG commented Nov 12, 2012

In the download function, it's currently set to use response.raw, via shutil.copyfileobj. It's easy to see that this avoids loading the whole downloaded file into memory, as opposed to the commented out line next to it that just writes response.content.

However, if I'm reading the 'requests' documentation correctly, response.content will automatically handle gzip/deflate and result in the correct file if the server uses these, while response.raw, being genuinely raw socket data, will not handle this, and the resulting file will not be what is expected.

Am I right or not? I don't currently have a compliant server to test that against.

@amnong
Copy link
Owner

amnong commented Nov 13, 2012

Well, I do agree it's wrong to use response.raw, I genuinely don't remember why I did that, but I do remember avoiding response.content for some reason, maybe because I thought or suspected it buffers the entire response body, I don't really remember. In any case I'm pretty swamped at work right now, and kinda lazy on the weekends :) If you happen to find a quick solution I'd appreciate a patch, and if you don't then I'll try to get around to testing and fixing this some time soon.

BTW it seems to me the potential here is for downloading an entirely corrupt file.

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

No branches or pull requests

2 participants