Update removeChunked to include 204/304

This commit is contained in:
Jason Smylnycky 2019-11-04 11:27:21 -05:00
parent 9bbe486c5e
commit a2bc4e4799
2 changed files with 40 additions and 8 deletions

View File

@ -24,7 +24,7 @@ module.exports = { // <--
* @api private * @api private
*/ */
removeChunked: function removeChunked(req, res, proxyRes) { removeChunked: function removeChunked(req, res, proxyRes) {
if (req.httpVersion === '1.0') { if (req.httpVersion === '1.0' || proxyRes.statusCode === 204 || proxyRes.statusCode === 304) {
delete proxyRes.headers['transfer-encoding']; delete proxyRes.headers['transfer-encoding'];
} }
}, },

View File

@ -408,6 +408,8 @@ describe('lib/http-proxy/passes/web-outgoing.js', function () {
describe('#removeChunked', function() { describe('#removeChunked', function() {
it('removes "transfer-encoding" response header on httpVersion 1.0', function() {
var proxyRes = { var proxyRes = {
headers: { headers: {
'transfer-encoding': 'hello' 'transfer-encoding': 'hello'
@ -420,4 +422,34 @@ describe('lib/http-proxy/passes/web-outgoing.js', function () {
expect(proxyRes.headers['transfer-encoding']).to.eql(undefined); expect(proxyRes.headers['transfer-encoding']).to.eql(undefined);
}); });
it('removes "transfer-encoding" response header on 204 response codes', function() {
var proxyRes = {
headers: {
'transfer-encoding': 'hello'
},
statusCode: 204
};
httpProxy.removeChunked({ httpVersion: '1.1' }, {}, proxyRes);
expect(proxyRes.headers['transfer-encoding']).to.eql(undefined);
});
it('removes "transfer-encoding" response header on 304 response codes', function() {
var proxyRes = {
headers: {
'transfer-encoding': 'hello'
},
statusCode: 304
};
httpProxy.removeChunked({ httpVersion: '1.1' }, {}, proxyRes);
expect(proxyRes.headers['transfer-encoding']).to.eql(undefined);
});
});
}); });