Node.js different behavior response

I have the following code:

var http = require('http');

http.createServer(function (request, response) {

  response.write("Hey! Ho!");

  setTimeout(function () {
    response.write("Let's Go!");
  }, 1000);

   setTimeout(function () {
    response.write("Let's Go!");
  }, 2000);

   setTimeout(function () {
    response.write("Let's Go!");
    response.end();
  }, 3000);

}).listen(8080);

When I run the following and I try accessing localhost:8080 on my browser the following happens:

 Hey! Ho! 
 // After one second 
 Let's Go! 
 // After one second 
 Let's Go! 
 // After one second 
 Let's Go!

When I run it on the terminal with curl http://localhost:8080 I get:

// Wait's for 3 seconds
Hey! Ho! Let's Go! Let's Go! Let's Go! 

Why don't I get the same behavior on the terminal as the browser?

Try with curl -N http://localhost:8080. -N disables output buffering.

Basically, curl waits for the entire response body to complete prior to displaying it by default (this is called buffering). Your browser however, will stream it, rendering the page as it receives it.

You can disable buffering in curl by using the -N or --no-buffer flag:

$ curl -N http://localhost:8080