You need to call res.end
in order to see the output in the browser.
Try, for example, adding this after res.write('hello')
:
setTimeout(function(){res.end();}, 5000);
After five seconds you'll see something like:
Hello world
world
My guess is that cURL shows output right away because it doesn't care about the content type, whereas the browser, which does care, may want more of the response before it shows anything.
You can also try streaming the response by changing the transfer encoding; check out this question for more info on that.