From 1a71a3c9d49cb9298aea68b55dab4bdce524d929 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 23 Feb 2009 22:43:50 +0100 Subject: [PATCH] fix bug in count-hosts.js was closing the chunked encoding before request ended --- count-hosts.js | 15 +++++++++++---- server.cc | 1 - 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/count-hosts.js b/count-hosts.js index caaf4a8289..6c639fcd0d 100644 --- a/count-hosts.js +++ b/count-hosts.js @@ -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"); - // } diff --git a/server.cc b/server.cc index 2d5257e2be..c8965e6c65 100644 --- a/server.cc +++ b/server.cc @@ -329,7 +329,6 @@ static oi_socket* new_connection return &connection->socket; } - // Reads a file into a v8 string. static Handle ReadFile ( const string& name