title: Node JS, delayed response
body: <pre><code>var http = require('http');
  var s = http.createServer(function (req, res) {
        res.writeHead(200, {'Content-Type': 'text/plain'});
        res.write('Hello\n');
        setInterval(function() {
            res.end(' World\n');
        },2000);
        console.log("Hello");
  });
  s.listen(8080);
  </code></pre>
  
  <p>After starting the above server, i run,</p>
  
  <pre><code>curl http://127.0.0.1:8080 
  </code></pre>
  
  <p>I get the required delay. output: </p>
  
  <pre><code>Hello &lt;2 seconds&gt; World
  </code></pre>
  
  <p>But in the browser the whole content loads after 2 seconds.</p>
  
  <pre><code>Hell World &lt;together after 2s&gt;
  </code></pre>
  
  <p>What am i doing wrong ?</p>