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
Fixing overwrite Blob/File type as Content-Type in browser. #1773
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks allowing the developer to explicitly set the
Content-Type
header. For example, if I need to sendContent-Type
ofapplication/octet-stream
for a PNG image, the browser overrides this and instead sendsimage/png
.For a use-case, this breaks sending attachments to the Microsoft Azure Rest API, which requires a
Content-Type
ofapplication/octet-stream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @adamdehaven, thanks for the report.
Although I think this is a breaking change and not sure why this was landed in a minor version(just missed the release version, I think a major version release is OK for this), in your case, I think actually you need to build a blob with typeapplication/octet-stream
, which could be done by something likeblob = blob.slice(0, blob.size, newType)
Here is a codepen: https://codepen.io/Gerhut/pen/YzqaOQY?editors=0012
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why I'd need to build a blob instead when this worked fine in v0.19.x?
Why delete the Content-Type value set in the code by the dev? If it's being explicitly set, that value should be respected. Axios should not "decide" which one to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“Theoretically” speaking, the dev also "set" a content-type in the body if they put a blob in body, which goes after headers and should overwrite the former definition.
Why the body changes header? Because header is used to define the body.
OK, I was just going to remove default content type header for the blob, not thought that there are many users use content type header to overwrite the blob type. I am OK with reverting it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Gerhut, when will #3289 be merged? The solution you mentioned in #1773 (comment) is not working for IE11.