-
-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Description
Describe the bug
I have a chunked file uploader, all data is to be sent as application/octet-stream in PUT in a binary stream.
This worked in 0.19.2.
However, 0.20.0 fails because of code added under #1773 "Fixing overwrite Blob/File type as Content-Type in browser.".
Line 21 lib/adapters/xhr.js:
if (
(utils.isBlob(requestData) || utils.isFile(requestData)) &&
requestData.type
) {
delete requestHeaders['Content-Type']; // Let the browser set it
}
This "fix" now breaks my application as it assumes the browser knows best - it doesn't. It also is semantically inaccurate to set the content type to something like image/jpeg when the data is 20MB chunk from the middle of a jpeg file - the data is NOT of content type image/jpeg.
The "fix" applied in #1773 appears to be fixing overwrite caused by setting of default content-type headers but this solution removes ANY control over the header by the developer when dealing with Blobs.
To Reproduce
Simply set content-type in a request where the payload is a blob.
Expected behavior
Axios should NOT delete the content type header set by the developer specifically on the request. The power to control this should remain with the calling code and not be dictated by the library.
Environment
- Axios Version 0.20.0
- Adapter XHR
- Browser ALL
- Browser Version ALL
- Node.js Version n/a
- OS: ALL (Linux, Windows, mac)