Skip to content

Commit

Permalink
Fixed stream reading method of BodyPartReader
Browse files Browse the repository at this point in the history
The method BodyPartHeader._read_chunk_from_stream from aiohttp.multipart
module was returning an zero length Byte object before reaching EOF
while reading a part in a muiltipart request.

Added missing virtualenv activation instructions in "CONTRIBUTING.rst".

Fixed a typo in the docs.

Fixes #1428.
  • Loading branch information
viotti committed Nov 27, 2016
1 parent 9a0bc18 commit 778ed06
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ If you like to use *virtualenv* please run:
$ cd aiohttp
$ virtualenv --python=`which python3` venv
$ . venv/bin/activate
For standard python *venv*:

.. code-block:: shell
$ cd aiohttp
$ python3 -m venv venv
$ . venv/bin/activate
For *virtualenvwrapper* (my choice):

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Pankaj Pandey
Pau Freixes
Paul Colomiets
Philipp A.
Rafael Viotti
Raúl Cumplido
"Required Field" <[email protected]>
Robert Lu
Expand Down
4 changes: 0 additions & 4 deletions aiohttp/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,6 @@ def _read_chunk_from_stream(self, size):
chunk = window[len(self._prev_chunk):idx]
if not chunk:
self._at_eof = True
if 0 < len(chunk) < len(sub) and not self._content_eof:
self._prev_chunk += chunk
self._at_eof = False
return b''
result = self._prev_chunk
self._prev_chunk = chunk
return result
Expand Down
2 changes: 1 addition & 1 deletion docs/web.rst
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ should use :meth:`Request.multipart` which returns :ref:`multipart reader

filename = mp3.filename

# You cannot relay on Content-Length if transfer is chunked.
# You cannot rely on Content-Length if transfer is chunked.
size = 0
with open(os.path.join('/spool/yarrr-media/mp3/', filename), 'wb') as f:
while True:
Expand Down

0 comments on commit 778ed06

Please sign in to comment.