title: Including timeout in Node.js http.get while getting large number of image downloads
body: <p>This is the code which I have been using to download images from URLs:</p>
  
  <pre><code>http.get(options, function (res) {
      res.on('data', function (data) {
          file.write(data);
      }).on('end', function () {
          file.end();
          console.log(file_name + ' downloaded ');
          cb(null, file.path);
      }).on('error', function (err) {
          console.log("Got error: " + err.message);
          cb(err, null);
      });
  });
  </code></pre>
  
  <p>How can I add a timeout for every request so that it doesn't stay on waiting for a response which is either large data or unresponsive?</p>