Skip to content
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

writing nested multipart messages does not work correctly #1525

Closed
terencehonles opened this issue Jan 4, 2017 · 1 comment
Closed

writing nested multipart messages does not work correctly #1525

terencehonles opened this issue Jan 4, 2017 · 1 comment
Labels

Comments

@terencehonles
Copy link
Contributor

Long story short

Write the following multipart message:

from aiohttp.multipart import MultipartWriter
with MultipartWriter('mixed') as root:
  with MultipartWriter('mixed') as subwriter1:
    subwriter1.append('first message')
  root.append(subwriter1)

  with MultipartWriter('mixed') as subwriter2:
    subwriter2.append('second message')
  root.append(subwriter2)

print(b''.join(root.serialize()).decode('ascii'))

Expected behaviour

--0d20b463316a462d839e93130150f5ef
Content-Type: multipart/mixed; boundary="05af9536a8374279a8bccc2ea099c82b"

--05af9536a8374279a8bccc2ea099c82b
Content-Type: text/plain; charset=utf-8
Content-Length: 13

first message
--05af9536a8374279a8bccc2ea099c82b--

--0d20b463316a462d839e93130150f5ef
Content-Type: multipart/mixed; boundary="1d4fdf1ddf8e46019da125c22c247649"

--1d4fdf1ddf8e46019da125c22c247649
Content-Type: text/plain; charset=utf-8
Content-Length: 14

second message
--1d4fdf1ddf8e46019da125c22c247649--

--0d20b463316a462d839e93130150f5ef--

Actual behaviour

--d3b608e9626a4f3cb2329fa01ebb1fce
Content-Type: application/octet-stream

--9310b9861e56425daf7ef0773fd2ae54
Content-Type: text/plain; charset=utf-8
Content-Length: 13

first message
--9310b9861e56425daf7ef0773fd2ae54--

--d3b608e9626a4f3cb2329fa01ebb1fce
Content-Type: application/octet-stream

--6fa9c511ee2d4a36bec615b15da6f1b2
Content-Type: text/plain; charset=utf-8
Content-Length: 14

second message
--6fa9c511ee2d4a36bec615b15da6f1b2--

--d3b608e9626a4f3cb2329fa01ebb1fce--

Steps to reproduce

Writer a nested multipart message as shown in the documentation.

"Fix": append(subwriter, headers=subwriter.headers)

I'll try to commit a patch, but just reporting the issue right now

terencehonles added a commit to terencehonles/aiohttp that referenced this issue Jan 6, 2017
When appending MultipartWriter objects to another MultipartWriter use
the subwriter's headers in the constructed BodyPartWriter

fixes issue aio-libs#1525
terencehonles added a commit to terencehonles/aiohttp that referenced this issue Jan 7, 2017
When appending MultipartWriter objects to another MultipartWriter use
the subwriter's headers in the constructed BodyPartWriter

fixes issue aio-libs#1525
fafhrd91 pushed a commit that referenced this issue Jan 21, 2017
…writing-nested-multipart-messages

fix #1525: add missing sub MultipartWriter headers
@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant