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

29 lines
749 B
JavaScript

function Process(request) {
//
// request.headers => { "Content-Length": "123" }
// request.http_version => "1.1"
//
log("Processing " + request.path + ". method: " + request.method);
// sends null on the last chunk.
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);
}
}
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");
//
}