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

Remove copy of body headers into request headers #1755

Closed
wants to merge 1 commit into from

Conversation

JohanLorenzo
Copy link

@JohanLorenzo JohanLorenzo commented Mar 27, 2017

Thank you for this library! Mozilla uses aiohttp to upload artifacts on Amazon S3.

We recently migrated to 2.0.0, which gave this particular side-effect: mozilla-releng/scriptworker#98. We noticed 'Content-Disposition' is now added to PUT request that contain a data payload (like a text/plain document). This has the unwanted effect to confuse Firefox when downloading artifacts from S3. Before then, artifacts could be directly displayed in browser, but now they are considered as blobs to be downloaded.

I found headers are now extended by the ones detected from the body. in d69838a. I'm not sure what was the context at the time.

What do these changes do?

With this patch, body headers are not included in the actual headers of a request. Based on d69838a, this was the behavior before this commit.

What do you think @fafhrd91 ?

Are there changes in behavior for the user?

That fixes a regression from 1.x.

Related issue number

Checklist

  • I think the code is well written
    (Side note: I just deleted some lines 😃 )

  • Unit tests for the changes exist
    It seems this particular area wasn't tested. I haven't changed the tests.

  • Documentation reflects the changes
    I'm not sure if changes are needed in the docs.

  • If you provide code modification, please add yourself to CONTRIBUTORS.txt

  • Add a new entry to CHANGES.rst

@fafhrd91
Copy link
Member

I do not think this is good solution. I think default expectation is to have content-disposition header if you send file. What if we change attachment to inline type? That should solve your problem

@JohanLorenzo
Copy link
Author

Thank you for your rapid answer 😃

I'm not sure to understand the necessity of Content-Disposition, though. Could you help me out, here?

From what I read on the Amazon S3 docs and the W3C specs, this is meant for clients to present the data differently (like changing a file name). Because this is not part of the HTTP specs, this is a nice to have, in my opinion.

Hence, forcing this header as a default on POST/PUT requests doesn't seem natural to me. Moreover, this might also represent a security risk. For example, one may not want to share the actual file name stored on a local disk. I also don't see a way filter out this header (with skip_auto_header for instance) before the request is sent.

@fafhrd91
Copy link
Member

aiohttp adds this header only if you send file object. I'll replace attachment with inline for 2.0.4 release
and think about removing header in 2.1.0. does it sound ok for you?

@JohanLorenzo
Copy link
Author

Sounds good to me. Let's go with this plan!

@fafhrd91
Copy link
Member

@kxepal what do you think about inline by default?

@JohanLorenzo another option is to drop content-disposition for non-multipart requests

@JohanLorenzo
Copy link
Author

Dropping it for non-multiparts makes sense to me.

@kxepal
Copy link
Member

kxepal commented Mar 27, 2017

+1 to drop. This header is not what to add for the requests. It's the server response header.

@fafhrd91
Copy link
Member

ok, then I'll leave attachment as default, and will drop content-disposition from stream

@fafhrd91
Copy link
Member

fixed in 2.0 and master. will release new version later today

@fafhrd91 fafhrd91 closed this Mar 27, 2017
@fafhrd91
Copy link
Member

2.0.4 is released

@JohanLorenzo
Copy link
Author

Thank you :)

@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
@JohanLorenzo JohanLorenzo deleted the fix-s3-upload branch October 29, 2019 09:31
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.

3 participants