From 2491f6b017124b4d1cb3bdd44c0cfe97a14a723a Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sat, 21 Jan 2017 13:18:52 -0800 Subject: [PATCH] Revert "fix #1525: add missing sub MultipartWriter headers" --- CHANGES.rst | 2 +- CONTRIBUTORS.txt | 1 - aiohttp/multipart.py | 6 +----- tests/test_multipart.py | 47 ----------------------------------------- 4 files changed, 2 insertions(+), 54 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 9e2f1cb5a2b..4f96f0101dd 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,7 +6,7 @@ CHANGES - Fix polls demo run application #1487 -- Fix sub-Multipart messages missing their headers on serialization #1525 +- 1.2.0 (2016-12-17) ------------------ diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 7570759ad92..8681f0c86ae 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -133,7 +133,6 @@ Steven Seguin Sviatoslav Bulbakha Taha Jahangir Taras Voinarovskyi -Terence Honles Thomas Grainger Tolga Tezel Vaibhav Sagar diff --git a/aiohttp/multipart.py b/aiohttp/multipart.py index 26740da1822..af7f19b12ae 100644 --- a/aiohttp/multipart.py +++ b/aiohttp/multipart.py @@ -670,11 +670,7 @@ class BodyPartWriter(object): """Multipart writer for single body part.""" def __init__(self, obj, headers=None, *, chunk_size=8192): - if isinstance(obj, MultipartWriter): - if headers is not None: - obj.headers.update(headers) - headers = obj.headers - elif headers is None: + if headers is None: headers = CIMultiDict() elif not isinstance(headers, CIMultiDict): headers = CIMultiDict(headers) diff --git a/tests/test_multipart.py b/tests/test_multipart.py index 2387647351b..e82e28e0251 100644 --- a/tests/test_multipart.py +++ b/tests/test_multipart.py @@ -838,12 +838,6 @@ def test_serialize_multipart(self): multipart = aiohttp.multipart.MultipartWriter(boundary=':') multipart.append('foo-bar-baz') multipart.append_json({'test': 'passed'}) - multipart.append_form({'test': 'passed'}) - multipart.append_form([('one', 1), ('two', 2)]) - sub_multipart = aiohttp.multipart.MultipartWriter(boundary='::') - sub_multipart.append('nested content') - sub_multipart.headers['X-CUSTOM'] = 'test' - multipart.append(sub_multipart) self.assertEqual( [b'--:\r\n', b'Content-Type: text/plain; charset=utf-8\r\n' @@ -851,37 +845,11 @@ def test_serialize_multipart(self): b'\r\n\r\n', b'foo-bar-baz', b'\r\n', - b'--:\r\n', b'Content-Type: application/json', b'\r\n\r\n', b'{"test": "passed"}', b'\r\n', - - b'--:\r\n', - b'Content-Type: application/x-www-form-urlencoded', - b'\r\n\r\n', - b'test=passed', - b'\r\n', - - b'--:\r\n', - b'Content-Type: application/x-www-form-urlencoded', - b'\r\n\r\n', - b'one=1&two=2', - b'\r\n', - - b'--:\r\n', - b'Content-Type: multipart/mixed; boundary="::"\r\nX-Custom: test', - b'\r\n\r\n', - b'--::\r\n', - b'Content-Type: text/plain; charset=utf-8\r\n' - b'Content-Length: 14', - b'\r\n\r\n', - b'nested content', - b'\r\n', - b'--::--\r\n', - b'', - b'\r\n', b'--:--\r\n', b''], list(self.part._serialize_multipart(multipart)) @@ -1014,13 +982,6 @@ def test_filename(self): self.part.set_content_disposition('related', filename='foo.html') self.assertEqual('foo.html', self.part.filename) - def test_wrap_multipart(self): - writer = aiohttp.multipart.MultipartWriter(boundary=':') - part = aiohttp.multipart.BodyPartWriter(writer) - self.assertEqual(part.headers, writer.headers) - part.headers['X-Custom'] = 'test' - self.assertEqual(part.headers, writer.headers) - class MultipartWriterTestCase(unittest.TestCase): @@ -1087,14 +1048,6 @@ def test_append_form(self): self.assertEqual(part.headers[CONTENT_TYPE], 'application/x-www-form-urlencoded') - def test_append_multipart(self): - subwriter = aiohttp.multipart.MultipartWriter(boundary=':') - subwriter.append_json({'foo': 'bar'}) - self.writer.append(subwriter, {CONTENT_TYPE: 'test/passed'}) - self.assertEqual(1, len(self.writer)) - part = self.writer.parts[0] - self.assertEqual(part.headers[CONTENT_TYPE], 'test/passed') - def test_serialize(self): self.assertEqual([b''], list(self.writer.serialize()))