Browse Source

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

v0.7.4-release
Ryan 16 years ago
parent
commit
1a71a3c9d4
  1. 15
      count-hosts.js
  2. 1
      server.cc

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

1
server.cc

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

Loading…
Cancel
Save