Skip to content

Commit

Permalink
Merge branch '3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Feb 26, 2018
2 parents ef560f5 + 5d5e9fd commit f2f8c74
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ python:
- &mainstream_python 3.6
- 3.6-dev
- nightly
- &pypy3 pypy3.5-5.8.0
- &pypy3 pypy3.5

install:
- &upgrade_python_toolset pip install --upgrade pip wheel setuptools
Expand Down
14 changes: 14 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ Changelog

.. towncrier release notes start
3.0.4 (2018-02-26)
==================

- Fix ``IndexError`` in HTTP request handling by server. (#2752)
- Fix MultipartWriter.append* no longer returning part/payload. (#2759)


3.0.3 (2018-02-25)
==================

- Relax ``attrs`` dependency to minimal actually supported version
17.0.3 The change allows to avoid version conflicts with currently
existing test tools.

3.0.2 (2018-02-23)
==================

Expand Down
12 changes: 5 additions & 7 deletions aiohttp/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
CONTENT_TRANSFER_ENCODING, CONTENT_TYPE)
from .helpers import CHAR, TOKEN, parse_mimetype, reify
from .http import HttpParser
from .payload import (BytesPayload, LookupError, Payload, StringPayload,
from .payload import (JsonPayload, LookupError, Payload, StringPayload,
get_payload, payload_type)


Expand Down Expand Up @@ -712,10 +712,10 @@ def append(self, obj, headers=None):
obj.headers.update(headers)
else:
obj._headers = headers
self.append_payload(obj)
return self.append_payload(obj)
else:
try:
self.append_payload(get_payload(obj, headers=headers))
return self.append_payload(get_payload(obj, headers=headers))
except LookupError:
raise TypeError

Expand Down Expand Up @@ -752,16 +752,14 @@ def append_payload(self, payload):
).encode('utf-8') + b'\r\n'

self._parts.append((payload, headers, encoding, te_encoding))
return payload

def append_json(self, obj, headers=None):
"""Helper to append JSON part."""
if headers is None:
headers = CIMultiDict()

data = json.dumps(obj).encode('utf-8')
self.append_payload(
BytesPayload(
data, headers=headers, content_type='application/json'))
return self.append_payload(JsonPayload(obj, headers=headers))

def append_form(self, obj, headers=None):
"""Helper to append form urlencoded part."""
Expand Down
14 changes: 8 additions & 6 deletions aiohttp/web_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,14 @@ def data_received(self, data):
500, exc))
self.close()
else:
for (msg, payload) in messages:
self._request_count += 1
self._messages.append((msg, payload))

if self._waiter:
self._waiter.set_result(None)
if messages:
# sometimes the parser returns no messages
for (msg, payload) in messages:
self._request_count += 1
self._messages.append((msg, payload))

if self._waiter is not None:
self._waiter.set_result(None)

self._upgrade = upgraded
if upgraded and tail:
Expand Down
4 changes: 2 additions & 2 deletions docs/multipart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ will include the file's basename::
part = root.append(open(__file__, 'rb'))

If you want to send a file with a different name, just handle the
:class:`BodyPartWriter` instance which :meth:`MultipartWriter.append` will
:class:`Payload` instance which :meth:`MultipartWriter.append` will
always return and set `Content-Disposition` explicitly by using
the :meth:`BodyPartWriter.set_content_disposition` helper::
the :meth:`Payload.set_content_disposition` helper::

part.set_content_disposition('attachment', filename='secret.txt')

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def build_extension(self, ext):
raise RuntimeError('Unable to determine version.')


install_requires = ['attrs>=17.4.0', 'chardet>=2.0,<4.0',
install_requires = ['attrs>=17.3.0', 'chardet>=2.0,<4.0',
'multidict>=4.0,<5.0',
'async_timeout>=1.2,<3.0',
'yarl>=1.0,<2.0']
Expand Down

0 comments on commit f2f8c74

Please sign in to comment.