Permalink
Browse files

Updated to work with Node 0.1.29

  • Loading branch information...
1 parent faea0c7 commit 7aafd32f758cce5ed5221758b4f18f6c787c89a4 @tautologistics committed Feb 22, 2010
Showing with 13 additions and 6 deletions.
  1. +2 −0 example-simple.js
  2. +2 −0 example-stream.js
  3. +4 −3 nodemachine.js
  4. +5 −3 runtests.js
View
@@ -35,5 +35,7 @@ server.trace = true;
server.addApp(new MyApp());
server.start();
+sys.puts("Ready for requests @ http://localhost:" + serverPort + "/");
+
//repl.start();
View
@@ -55,5 +55,7 @@ server.trace = true;
server.addApp(new MyApp());
server.start();
+sys.puts("Ready for requests @ http://localhost:" + serverPort + "/");
+
//repl.start();
View
@@ -568,7 +568,7 @@ Response.prototype.sendBody = function Response__sendBody (chunk, encoding) {
this._buffer.push([chunk, encoding]);
else {
this.flushBody();
- this._res.sendBody(chunk, encoding); //TODO: apply encoding method here
+ this._res.write(chunk, encoding); //TODO: apply encoding method here
}
}
@@ -582,13 +582,14 @@ Response.prototype.sendHeaders = function Response__sendHeaders () {
Response.prototype.flushBody = function Response__flushBody () {
this.sendHeaders();
this._buffer.forEach(function (element, index, array) {
- this._res.sendBody(element[0], element[1]); //TODO: apply encoding method here
+ this._res.write(element[0], element[1]); //TODO: apply encoding method here
}, this);
}
Response.prototype.finish = function Response__finish () {
this.flushBody();
- return(this._res.finish());
+ //return(this._res.finish());
+ return(this._res.close());
}
Response.prototype.setHeader = function Response__setHeader (name, value) {
View
@@ -69,12 +69,13 @@ function runTest(currentTest) {
sys.puts("Running test [" + (currentTest + 1) + "] " + testScenario.name);
var body = '';
- request.finish(function (response) {
+// request.finish(function (response) {
+ request.addListener("response", function (response) {
response.setBodyEncoding("utf8");
- response.addListener("body", function (chunk) {
+ response.addListener("data", function (chunk) {
body += chunk;
});
- response.addListener("complete", function () {
+ response.addListener("end", function () {
if (!((testScenario.checkBody == null) || testScenario.checkBody(body))) {
failedTests[testScenario.name] = 1;
sys.puts(" Bad body");
@@ -94,6 +95,7 @@ function runTest(currentTest) {
sys.puts(" Bad headers");
}
});
+ request.close();
}
runTest(0);

0 comments on commit 7aafd32

Please sign in to comment.