0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-25 08:19:38 +01:00
nodejs/count-hosts.js

29 lines
749 B
JavaScript
Raw Normal View History

2009-02-20 17:06:07 +01:00
function Process(request) {
//
// request.headers => { "Content-Length": "123" }
// request.http_version => "1.1"
//
2009-02-21 21:00:40 +01:00
log("Processing " + request.path + ". method: " + request.method);
2009-02-22 18:15:18 +01:00
// sends null on the last chunk.
2009-02-21 21:00:40 +01:00
request.onBody = function (chunk) {
log("got chunk length: " + chunk.length.toString(16) );
if(chunk) {
this.respond(chunk.length.toString(16) + "\r\n" + chunk + "\r\n");
} else {
this.respond("0\r\n\r\n");
this.respond(null);
}
2009-02-20 17:06:07 +01:00
}
2009-02-22 18:15:18 +01:00
request.respond("HTTP/1.0 200 OK\r\n");
request.respond("Content-Type: text-plain\r\n");
request.respond("Transfer-Encoding: chunked\r\n");
request.respond("\r\n");
//request.respond("Content-Length: 6\r\n\r\nhello\n");
//
2009-02-20 17:06:07 +01:00
}