mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Merge pull request #742 from jugglinmike/option-content-length
Set `Content-Length` header for OPTIONS requests
This commit is contained in:
commit
3194d819b4
@ -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';
|
||||
}
|
||||
},
|
||||
|
||||
@ -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() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user