a,
I am completely new to node.js. Starting to try, I follow the introduction made by Ryan Dahl ( http://www.youtube.com/watch?v=jo_B4LTHi3I ) and at that moment (around 0:17:00) there is an explanation of how the server processes the responses,
The main example is getting "hi" output from a web server, and then after 2 seconds it comes to the "world", this code should do it
//Require the webserver library var http = require('http'); var server = http.createServer(function(req, res) { res.writeHead(200, { 'content-type' : 'text-plain' }); res.write('Hello\n'); //Asynchronous behavior setTimeout(function() { res.end('World\n'); }, 2000); }); server.listen(3000);
So, I run it and I get Hello World, but there is only one response from the server with the full result, i.e. request> 2 sec> 'Hello World'. Instead of query> Hello> 2 secs> World.
Why is this ?, How can I change this behavior?
I am using v0.8.18, curl -i http://localhost:3000 returns the correct headers ... HTTP/1.1 200 OK content-type: text-plain Date: Sat, 26 Jan 2013 18:10:05 GMT Connection: keep-alive Transfer-Encoding: chunked
source share