I have a question about the code below: I would need a confirmation that all the processing done in proxyRes event will be done asynchronously and all processing time in it won't affect the proxying time.
Thank you in advance for help in this
var server = http.createServer(function (req, res) {
console.time();
var proxy = httpProxy.createProxyServer();
proxy.web(req, res, {
target: 'https://gdev.sserver.be/api/host1/account',
});
console.timeEnd();
proxy.on('proxyRes', function (proxyRes, req, res) {
//console.log('RAW Response from the target', JSON.stringify(proxyRes.headers, true, 2));
proxyRes.on('data', function (chunk) {
console.log('resp => ' + chunk);
connection.query('INSERT INTO test SET ?', {content: chunk}, function(err, result) {
if (err) throw err;
console.log('writing in db');
});
});
proxy.close();
proxy = null;
});
}).listen(3000);