title: Node.js url methods return null
body: <p>I'm trying to get node.js to print http request properties to the browser. However, the properties of the request url either return null or don't print at all. Here is the code for the server (server.js):</p>
  
  <pre><code>var http = require('http');
  var url = require('url');
  function start() {
   function onRequest(request, response) {
      var pathname = url.parse(request.url, true).pathname;
      var protocol = url.parse(request.url, true).protocol;
      var hostname = url.parse(request.url, true).host;
      var path = url.parse(request.url, true).path;
      response.writeHead(200, {"Content-Type": "text/plain"}); 
      response.write("Hello World"); //this is the text that is sent back
      response.write("\nThe HTTP response is " + response.statusCode);
      response.write("\nRequest for "+ pathname +" has been received. The request url is " + request.url + " and our protocol is " + protocol +".Also, our host is " + hostname);
      response.write("\nThe concatenated path is " + path);
      response.end(); //this is the end of the response
   }
   var new_server = http.createServer(onRequest).listen(8888);
  } //end of start function
  exports.start = start; 
  </code></pre>
  
  <p>And the index file that executes this is index.js</p>
  
  <pre><code>var server = require("./server");
  console.log("To see what the sever responds with, go to localhost:8888.");
  server.start();
  </code></pre>
  
  <p>My browser output is, when I type in the url bar localhost:8888</p>
  
  <p>Hello World
  The HTTP response is 200
  Request for / has been received. The request url is / and our protocol is null.Also, our host is null
  The concatenated path is /</p>
  
  <p>I need to get the url properties. Thank you.</p>