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

Send raw files as is #153

Merged
merged 1 commit into from
Sep 29, 2014
Merged

Send raw files as is #153

merged 1 commit into from
Sep 29, 2014

Conversation

kxepal
Copy link
Member

@kxepal kxepal commented Sep 17, 2014

This fixes the behavior when on attempt to POST file object or BytesIO
aiohttp instead of sending their content as is wraps them with multipart
request what isn't welcome for most cases.

This commit changes that behavior: if you call aiohttp.request with
data parameter as file or BytesIO, it will send them as raw binary
chunked stream. In case of files, when Content-Type header isn't set
aiohttp will try to guess the mimetype using the mimetypes module.
Otherwise default 'application/octet-stream' will be used.

There are also checks for StringIO and files opened in text mode: both
aren't allowed since they may cause to send data using not the encoding
you expected to.

This fixes the behavior when on attempt to POST file object or BytesIO
aiohttp instead of sending their content as is wraps them with multipart
request what isn't welcome for most cases.

This commit changes that behavior: if you call aiohttp.request with
data parameter as file or BytesIO, it will send them as raw binary
chunked stream. In case of files, when Content-Type header isn't set
aiohttp will try to guess the mimetype using the mimetypes module.
Otherwise default 'application/octet-stream' will be used.

There are also checks for StringIO and files opened in text mode: both
aren't allowed since they may cause to send data using not the encoding
you expected to.
kxepal added a commit to aio-libs/aiocouchdb that referenced this pull request Sep 17, 2014
@kxepal
Copy link
Member Author

kxepal commented Sep 29, 2014

Everyone happy if I merge this?

@fafhrd91
Copy link
Member

Should your change belong to FormData class?

On Monday, September 29, 2014, Alexander Shorin notifications@github.com
wrote:

Everyone happy if I merge this?


Reply to this email directly or view it on GitHub
#153 (comment).

@kxepal
Copy link
Member Author

kxepal commented Sep 29, 2014

Why? It shares nothing with FormData and is about sending raw binary data.

@fafhrd91
Copy link
Member

Ok. Makes sense. Lgtm

On Monday, September 29, 2014, Alexander Shorin notifications@github.com
wrote:

Why? It shares nothing with FormData and is about sending raw binary data.


Reply to this email directly or view it on GitHub
#153 (comment).

kxepal added a commit that referenced this pull request Sep 29, 2014
@kxepal kxepal merged commit 0289ce8 into aio-libs:master Sep 29, 2014
@lock
Copy link

lock bot commented Oct 30, 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 30, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants