2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-14 18:42:33 +03:00

fix(headers): fixed common Content-Type header merging; (#5832)

This commit is contained in:
Dmitriy Mozgovoy
2023-08-26 16:26:50 +03:00
committed by GitHub
parent d8b4ca0ea5
commit 8fda2766b1
4 changed files with 33 additions and 23 deletions
+3 -10
View File
@@ -8,10 +8,6 @@ import toURLEncodedForm from '../helpers/toURLEncodedForm.js';
import platform from '../platform/index.js';
import formDataToJSON from '../helpers/formDataToJSON.js';
const DEFAULT_CONTENT_TYPE = {
'Content-Type': undefined
};
/**
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
* of the input
@@ -150,17 +146,14 @@ const defaults = {
headers: {
common: {
'Accept': 'application/json, text/plain, */*'
'Accept': 'application/json, text/plain, */*',
'Content-Type': undefined
}
}
};
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
defaults.headers[method] = {};
});
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
});
export default defaults;