title: Making request to localhost with Node client?
body: <p>I have a very simple node server running on port 8080, and I'm trying to get an equally simple node client to hit this server.</p>
  
  <p>Why does this code <strong>not</strong> work:</p>
  
  <pre><code>var http = require('https');
  
  http.get('http://localhost:8080/headers', function(response) {
      console.log('Status:', response.statusCode);
      console.log('Headers: ', response.headers);
      response.pipe(process.stdout);
  });
  </code></pre>
  
  <p>but this code <strong>does</strong> work?:</p>
  
  <pre><code>var http = require('http');
  var client = http.createClient(8080, 'localhost');
  var request = client.request('GET', '/headers');
  request.end();
  request.on("response", function (response) {
      console.log('Status:', response.statusCode);
      console.log('Headers: ', response.headers);
      response.pipe(process.stdout);
  });
  </code></pre>