mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Merge pull request #961 from Turbo87/transfer-encoding-fix
Remove "transfer-encoding" header if "content-length" is set to zero
This commit is contained in:
commit
d19be83858
@ -32,6 +32,7 @@ web_o = Object.keys(web_o).map(function(pass) {
|
||||
if((req.method === 'DELETE' || req.method === 'OPTIONS')
|
||||
&& !req.headers['content-length']) {
|
||||
req.headers['content-length'] = '0';
|
||||
delete req.headers['transfer-encoding'];
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -22,6 +22,18 @@ describe('lib/http-proxy/passes/web.js', function() {
|
||||
webPasses.deleteLength(stubRequest, {}, {});
|
||||
expect(stubRequest.headers['content-length']).to.eql('0');
|
||||
});
|
||||
|
||||
it('should remove `transfer-encoding` from empty DELETE requests', function() {
|
||||
var stubRequest = {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'transfer-encoding': 'chunked'
|
||||
}
|
||||
};
|
||||
webPasses.deleteLength(stubRequest, {}, {});
|
||||
expect(stubRequest.headers['content-length']).to.eql('0');
|
||||
expect(stubRequest.headers).to.not.have.key('transfer-encoding');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#timeout', function() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user