From 9879a8856bf60b61c58938fb43e0e794155a0157 Mon Sep 17 00:00:00 2001 From: Terence Honles Date: Tue, 31 Jan 2017 20:49:25 -0800 Subject: [PATCH] fix #1526: multipart messages should consume their epilogue (#1532) Currently a multipart message epilogue is left unread which when nested in another multipart message causes a ValueError to be raised because the parent reader expects to find its multipart boundary not the sub-message's epilogue. fixes issue #1526 --- aiohttp/multipart.py | 1 + tests/test_multipart.py | 1 + tests/test_py35/test_multipart_35.py | 1 + 3 files changed, 3 insertions(+) diff --git a/aiohttp/multipart.py b/aiohttp/multipart.py index be8cb2e0278..7fc260f3022 100644 --- a/aiohttp/multipart.py +++ b/aiohttp/multipart.py @@ -631,6 +631,7 @@ def _read_boundary(self): pass elif chunk == self._boundary + b'--': self._at_eof = True + yield from self._readline() else: raise ValueError('Invalid boundary %r, expected %r' % (chunk, self._boundary)) diff --git a/tests/test_multipart.py b/tests/test_multipart.py index 708ad0e1560..031881e54a5 100644 --- a/tests/test_multipart.py +++ b/tests/test_multipart.py @@ -603,6 +603,7 @@ def test_release(self): b'\r\n' b'passed\r\n' b'----:----\r\n' + b'\r\n' b'--:--')) yield from reader.release() self.assertTrue(reader.at_eof()) diff --git a/tests/test_py35/test_multipart_35.py b/tests/test_py35/test_multipart_35.py index cb9300fd296..d6bb2394fd6 100644 --- a/tests/test_py35/test_multipart_35.py +++ b/tests/test_py35/test_multipart_35.py @@ -52,6 +52,7 @@ async def test_async_for_reader(loop): b'\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03K\xcc\xcc\xcf())' b'\xe0\x02\x00\xd6\x90\xe2O\x08\x00\x00\x00', b'--::--', + b'', b'--:--', b'']))) idata = iter(data)