-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Method "read_chunk" of "BodyPartReader" returns zero bytes before eof #1428
Comments
I think I've traced the problem back to lines 335 to 338 of multipart.py. From revision 6edd825, it seems those lines deal with the case of a small multipart body, but I'm not sure about this. In lines 337 and 338 an empty bytes object is returned explicitly with Removing those lines did not affect the outcome of the test battery in my environment. I can provide a PR if you like. |
@kxepal ? |
@viotti While it looks as a good idea to switch to Feel free to submit a patch anyway! The |
Fixed by #1431 The fix is released as aiohttp 1.1.6 |
Long story short
I've implemented a multipart file upload handler inspired on code from the docs. My code is truncating part's data. I believe the problem is in the method
_read_chunk_from_stream
, which is used byread_chunk
ofBodyPartReader
. That method is returning a zero-lengthbytearray
before the part's EOF. This is the pseudo-code.Expected behaviour
The loop ends when all the part's data has been read.
Actual behaviour
The loop ends before the part's data is exhausted, i.e., chunk becomes a zero-length
bytearray
prematurely.Steps to reproduce
The code is part of a large web application so it's hard for me to give reproducible steps. But replacing the break condition to
if not part._at_eof
made the problem go away.Your environment
Aiohttp 1.1.5
Python 3.5.1 from PSF
macOS Sierra 10.12.1
The text was updated successfully, but these errors were encountered: