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
|
* @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'];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -408,16 +408,48 @@ describe('lib/http-proxy/passes/web-outgoing.js', function () {
|
|||||||
|
|
||||||
|
|
||||||
describe('#removeChunked', function() {
|
describe('#removeChunked', function() {
|
||||||
var proxyRes = {
|
|
||||||
headers: {
|
it('removes "transfer-encoding" response header on httpVersion 1.0', function() {
|
||||||
'transfer-encoding': 'hello'
|
var proxyRes = {
|
||||||
}
|
headers: {
|
||||||
};
|
'transfer-encoding': 'hello'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
httpProxy.removeChunked({ httpVersion: '1.0' }, {}, proxyRes);
|
httpProxy.removeChunked({ httpVersion: '1.0' }, {}, proxyRes);
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
expect(proxyRes.headers['transfer-encoding']).to.eql(undefined);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user