mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
639 B
23 lines
639 B
16 years ago
|
function encode(data) {
|
||
|
var chunk = data.toString();
|
||
|
return chunk.length.toString(16) + "\r\n" + chunk + "\r\n";
|
||
|
}
|
||
|
|
||
|
function Process(request) {
|
||
|
// onBody sends null on the last chunk.
|
||
|
request.onBody = function (chunk) {
|
||
|
if(chunk) {
|
||
|
this.respond(encode(chunk));
|
||
|
} else {
|
||
|
this.respond(encode("\n"));
|
||
|
this.respond("0\r\n\r\n");
|
||
|
this.respond(null); // signals end-of-request
|
||
|
}
|
||
|
}
|
||
|
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");
|
||
|
}
|
||
|
|