diff --git a/lib/http-proxy/passes/web-incoming.js b/lib/http-proxy/passes/web-incoming.js index 572c11a8c..369171eb4 100644 --- a/lib/http-proxy/passes/web-incoming.js +++ b/lib/http-proxy/passes/web-incoming.js @@ -29,7 +29,8 @@ web_o = Object.keys(web_o).map(function(pass) { */ function deleteLength(req, res, options) { - if(req.method === 'DELETE' && !req.headers['content-length']) { + if((req.method === 'DELETE' || req.method === 'OPTIONS') + && !req.headers['content-length']) { req.headers['content-length'] = '0'; } }, diff --git a/test/lib-http-proxy-passes-web-incoming-test.js b/test/lib-http-proxy-passes-web-incoming-test.js index f70001035..f2c6f1304 100644 --- a/test/lib-http-proxy-passes-web-incoming-test.js +++ b/test/lib-http-proxy-passes-web-incoming-test.js @@ -5,14 +5,23 @@ var webPasses = require('../lib/http-proxy/passes/web-incoming'), describe('lib/http-proxy/passes/web.js', function() { describe('#deleteLength', function() { - it('should change `content-length`', function() { + it('should change `content-length` for DELETE requests', function() { var stubRequest = { method: 'DELETE', headers: {} }; webPasses.deleteLength(stubRequest, {}, {}); expect(stubRequest.headers['content-length']).to.eql('0'); - }) + }); + + it('should change `content-length` for OPTIONS requests', function() { + var stubRequest = { + method: 'OPTIONS', + headers: {} + }; + webPasses.deleteLength(stubRequest, {}, {}); + expect(stubRequest.headers['content-length']).to.eql('0'); + }); }); describe('#timeout', function() {