mirror of
https://github.com/tenrok/axios.git
synced 2026-06-11 18:02:32 +03:00
fix(formdata): fixed automatic addition of the Content-Type header for FormData in non-browser environments; (#5917)
This commit is contained in:
+7
-2
@@ -61,11 +61,16 @@ export default isXHRAdapterSupported && function (config) {
|
||||
}
|
||||
}
|
||||
|
||||
let contentType;
|
||||
|
||||
if (utils.isFormData(requestData)) {
|
||||
if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
|
||||
requestHeaders.setContentType(false); // Let the browser set it
|
||||
} else {
|
||||
requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks
|
||||
} else if(!requestHeaders.getContentType(/^\s*multipart\/form-data/)){
|
||||
requestHeaders.setContentType('multipart/form-data'); // mobile/desktop app frameworks
|
||||
} else if(utils.isString(contentType = requestHeaders.getContentType())){
|
||||
// fix semicolon duplication issue for ReactNative FormData implementation
|
||||
requestHeaders.setContentType(contentType.replace(/^\s*(multipart\/form-data);+/, '$1'))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user