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

Making content-type header case insensitive

closes #89
This commit is contained in:
mzabriskie
2015-07-23 09:39:59 -07:00
parent 3b10b6a6c5
commit 3c4dfe8a81
2 changed files with 33 additions and 2 deletions
+10 -2
View File
@@ -20,8 +20,16 @@ module.exports = {
}
if (utils.isObject(data) && !utils.isFile(data) && !utils.isBlob(data)) {
// Set application/json if no Content-Type has been specified
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
headers['Content-Type'] = 'application/json;charset=utf-8';
if (!utils.isUndefined(headers)) {
utils.forEach(headers, function (val, key) {
if (key.toLowerCase() === 'content-type') {
headers['Content-Type'] = val;
}
});
if (utils.isUndefined(headers['Content-Type'])) {
headers['Content-Type'] = 'application/json;charset=utf-8';
}
}
return JSON.stringify(data);
}