title: Waiting for an async HTTP request to complete
body: <p>This question has been asked in various ways already here, and I understand the problem pretty well.  The general solution is to invoke callbacks for handling HTTP results, but I'm specifically wanting to avoid that.</p>
  
  <p>I imagined I could use a "are we done yet" flag to keep things working, but this isn't working as expected.</p>
  
  <pre><code>//
  //  Test the IP the comment came-from.
  //
  exports.testJSON = function ( obj )
  {
      var ip     = obj['ip'] || "";
      var result = null;
      var done   = false;
  
      //
      //  The URL request we're going to make
      //
      var options = {
          host: 'www.stopforumspam.com',
          port: 80,
          path: '/api?ip=' + ip
      };
  
      //
      // A GET request
      //
      var re = http.request(options, function(res) {
          var str = '';
  
          res.on('data', function(chunk) {
              console.log( "Got data " + chunk );
              str += chunk;
          });
          res.on('end', function() {
              console.log( "Got END" );
              result = "..... ";
              done = true;
          });
        }).on('error', function(e) {
           done = true;
           console.log("Got error: ", e);
       });
  
     re.end();
  
     while( ! done ) {
     }
  
     return( result );
  };
  </code></pre>
  
  <p>Sadly this doesn't work - the busy look just spins indefinitely, and I see no console-logging to indicate that I'm receiving data.</p>
  
  <p>Adding in "process.nextTick()" to the "while(!done){}" loop makes no difference either.</p>
  
  <p>Surely I don't need to rework my whole plugin system to cope with a different approach, and the callback updating the "done" flag will work, somehow?</p>