-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Related to axios/axios#5090
- Loading branch information
Showing
3 changed files
with
87 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
diff --git a/dist/axios.js b/dist/axios.js | ||
index 5c85690b0eb51c137e8febb65fe37a51e1ae11bc..96dfd12f78c1228c97187ff578c1ceb49e2f1a54 100644 | ||
--- a/dist/axios.js | ||
+++ b/dist/axios.js | ||
@@ -1516,7 +1516,7 @@ | ||
} | ||
self[key || _header] = normalizeValue(_value); | ||
} | ||
- if (utils.isPlainObject(header)) { | ||
+ if (utils.isPlainObject(header) || header instanceof AxiosHeaders) { | ||
utils.forEach(header, function (_value, _header) { | ||
setHeader(_value, _header, valueOrRewrite); | ||
}); | ||
@@ -2342,7 +2342,7 @@ | ||
config.method = (config.method || this.defaults.method || 'get').toLowerCase(); | ||
|
||
// Flatten headers | ||
- var defaultHeaders = config.headers && utils.merge(config.headers.common, config.headers[config.method]); | ||
+ var defaultHeaders = config.headers && utils.merge(this.defaults.headers.common, this.defaults.headers[config.method]); | ||
defaultHeaders && utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function cleanHeaderConfig(method) { | ||
delete config.headers[method]; | ||
}); | ||
diff --git a/dist/esm/axios.js b/dist/esm/axios.js | ||
index b08fb87e5845d036d93545d9754f81762c6ca6a3..1b94a2a947957800d728effa56a966563dcfaad5 100644 | ||
--- a/dist/esm/axios.js | ||
+++ b/dist/esm/axios.js | ||
@@ -1622,7 +1622,7 @@ Object.assign(AxiosHeaders.prototype, { | ||
self[key || _header] = normalizeValue(_value); | ||
} | ||
|
||
- if (utils.isPlainObject(header)) { | ||
+ if (utils.isPlainObject(header) || header instanceof AxiosHeaders) { | ||
utils.forEach(header, (_value, _header) => { | ||
setHeader(_value, _header, valueOrRewrite); | ||
}); | ||
@@ -2611,8 +2611,8 @@ class Axios { | ||
|
||
// Flatten headers | ||
const defaultHeaders = config.headers && utils.merge( | ||
- config.headers.common, | ||
- config.headers[config.method] | ||
+ this.defaults.headers.common, | ||
+ this.defaults.headers[config.method] | ||
); | ||
|
||
defaultHeaders && utils.forEach( | ||
diff --git a/lib/core/Axios.js b/lib/core/Axios.js | ||
index 31f8b531dc5b1aa70873de19f21efe6d4ed75deb..11b8b922a12df0ecf472ef0e3822639b9c0aed27 100644 | ||
--- a/lib/core/Axios.js | ||
+++ b/lib/core/Axios.js | ||
@@ -69,8 +69,8 @@ class Axios { | ||
|
||
// Flatten headers | ||
const defaultHeaders = config.headers && utils.merge( | ||
- config.headers.common, | ||
- config.headers[config.method] | ||
+ this.defaults.headers.common, | ||
+ this.defaults.headers[config.method] | ||
); | ||
|
||
defaultHeaders && utils.forEach( | ||
diff --git a/lib/core/AxiosHeaders.js b/lib/core/AxiosHeaders.js | ||
index 68e098a0f7e910779fffd5d5ff2c684d8dd7e5e6..87f745f2071c330c050cc51fab5e950d426e05b4 100644 | ||
--- a/lib/core/AxiosHeaders.js | ||
+++ b/lib/core/AxiosHeaders.js | ||
@@ -105,7 +105,7 @@ Object.assign(AxiosHeaders.prototype, { | ||
self[key || _header] = normalizeValue(_value); | ||
} | ||
|
||
- if (utils.isPlainObject(header)) { | ||
+ if (utils.isPlainObject(header) || header instanceof AxiosHeaders) { | ||
utils.forEach(header, (_value, _header) => { | ||
setHeader(_value, _header, valueOrRewrite); | ||
}); |
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
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