Node.js http module not closing the connection when no 'data' listener is set
Consider the following code: const http = require(‘http’) const req = http.request({hostname: ‘www.example.com’}, res=>{ console.log(‘Response received’) res.on(‘data’,data=>{ console.log(‘Received: ‘+data) }) res.on(‘end’,()=>{ console.log(‘Connection ended’) }) }) req.end() As expected, it prints: Response received Received data Connection ended But when I remove the event listener for ‘data’, like this: const http = require(‘http’) const req = http.request({hostname:… Read More Node.js http module not closing the connection when no 'data' listener is set