diff --git a/lib/core/dispatchRequest.js b/lib/core/dispatchRequest.js index c8267ad..7768e00 100644 --- a/lib/core/dispatchRequest.js +++ b/lib/core/dispatchRequest.js @@ -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]; + } } ); diff --git a/test/specs/headers.spec.js b/test/specs/headers.spec.js index 5a8b1a8..6c2aba3 100644 --- a/test/specs/headers.spec.js +++ b/test/specs/headers.spec.js @@ -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(); + }); + }); + }); });