fix bug in count-hosts.js was closing the chunked encoding before request ended

This commit is contained in:
Ryan 2009-02-23 22:43:50 +01:00
Родитель aa72b99917
Коммит 1a71a3c9d4
2 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -1,3 +1,8 @@
function encode(i) {
var string = i.toString();
var r = string.length.toString(16) + "\r\n" + string + "\r\n";
return r;
}
function Process(request) {
@ -6,13 +11,18 @@ function Process(request) {
// request.http_version => "1.1"
//
//log("Processing " + request.path + ". method: " + request.method);
var s = "";
// sends null on the last chunk.
request.onBody = function (chunk) {
if(chunk) {
//log( "got chunk length: " + chunk.length.toString() );
this.respond(chunk.length.toString(16) + "\r\n" + chunk + "\r\n");
//this.respond(chunk.length.toString(16) + "\r\n" + evalchunk + "\r\n");
s += chunk;
} else {
var output = eval(s);
this.respond(encode(output));
this.respond(encode("\n"));
this.respond("0\r\n\r\n");
this.respond(null);
}
@ -22,8 +32,5 @@ function Process(request) {
request.respond("Content-Type: text-plain\r\n");
request.respond("Transfer-Encoding: chunked\r\n");
request.respond("\r\n");
request.respond("0\r\n\r\n");
//request.respond("Content-Length: 6\r\n\r\nhello\n");
//
}

Просмотреть файл

@ -329,7 +329,6 @@ static oi_socket* new_connection
return &connection->socket;
}
// Reads a file into a v8 string.
static Handle<String> ReadFile
( const string& name