2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00

Bug/allow header to contain http verb keys #1252 (#1258)

* Failing test for #1252

* Only delete header keys that match an HTTP verb if the value is a non-string

Co-authored-by: David Ko <david.ko@pvtmethod.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
David Ko
2020-05-22 15:26:10 -04:00
committed by GitHub
parent 1cdf9e4039
commit 920510b3a6
2 changed files with 16 additions and 1 deletions
+3 -1
View File
@@ -43,7 +43,9 @@ module.exports = function dispatchRequest(config) {
utils.forEach(
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
function cleanHeaderConfig(method) {
delete config.headers[method];
if (typeof config.headers[method] !== 'string') {
delete config.headers[method];
}
}
);
+13
View File
@@ -86,4 +86,17 @@ describe('headers', function () {
done();
});
});
describe('when a header key matches an HTTP verb', function() {
it('preserves the header value', function(done) {
axios.post('/foo', null, { 'headers': { 'delete': 'test' } });
getAjaxRequest().then(function (request) {
var headerValue = request.requestHeaders['delete'];
expect(headerValue).toEqual('test');
done();
});
});
});
});