mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Update removeChunked to include 204/304
This commit is contained in:
parent
9bbe486c5e
commit
a2bc4e4799
@ -24,7 +24,7 @@ module.exports = { // <--
|
||||
* @api private
|
||||
*/
|
||||
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'];
|
||||
}
|
||||
},
|
||||
|
||||
@ -408,6 +408,8 @@ describe('lib/http-proxy/passes/web-outgoing.js', function () {
|
||||
|
||||
|
||||
describe('#removeChunked', function() {
|
||||
|
||||
it('removes "transfer-encoding" response header on httpVersion 1.0', function() {
|
||||
var proxyRes = {
|
||||
headers: {
|
||||
'transfer-encoding': 'hello'
|
||||
@ -420,4 +422,34 @@ describe('lib/http-proxy/passes/web-outgoing.js', function () {
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user