test: Fix many tests for http streams2 refactor
authorisaacs <i@izs.me>
Thu, 13 Dec 2012 17:52:08 +0000 (09:52 -0800)
committerisaacs <i@izs.me>
Sat, 15 Dec 2012 01:46:23 +0000 (17:46 -0800)
test/simple/test-cluster-http-pipe.js
test/simple/test-domain-http-server.js
test/simple/test-http-abort-client.js
test/simple/test-http-client-agent.js
test/simple/test-http-client-pipe-end.js

index 46d429a..7123bf6 100644 (file)
@@ -53,6 +53,7 @@ http.createServer(function(req, res) {
 }).listen(common.PIPE, function() {
   var self = this;
   http.get({ socketPath: common.PIPE, path: '/' }, function(res) {
+    res.resume();
     res.on('end', function(err) {
       if (err) throw err;
       process.send('DONE');
index f9962d3..b337f00 100644 (file)
@@ -33,6 +33,7 @@ var disposeEmit = 0;
 
 var server = http.createServer(function(req, res) {
   var dom = domain.create();
+  req.resume();
   dom.add(req);
   dom.add(res);
 
index 6acdd6f..f15238a 100644 (file)
@@ -46,13 +46,21 @@ server.listen(common.PORT, function() {
 
     res.on('data', function(chunk) {
       console.log('Read ' + chunk.length + ' bytes');
-      console.log(chunk.toString());
+      console.log(' chunk=%j', chunk.toString());
     });
 
     res.on('end', function() {
       console.log('Response ended.');
     });
 
+    res.on('aborted', function() {
+      console.log('Response aborted.');
+    });
+
+    res.socket.on('close', function() {
+      console.log('socket closed, but not res');
+    })
+
     // it would be nice if this worked:
     res.on('close', function() {
       console.log('Response aborted');
index f7112e3..aedf64b 100644 (file)
@@ -61,6 +61,7 @@ function request(i) {
         server.close();
       }
     });
+    res.resume();
   });
 }
 
index 7cb592e..51edebb 100644 (file)
@@ -26,6 +26,7 @@ var assert = require('assert');
 var http = require('http');
 
 var server = http.createServer(function(req, res) {
+  req.resume();
   req.once('end', function() {
     res.writeHead(200);
     res.end();
@@ -50,9 +51,9 @@ server.listen(common.PIPE, function() {
 function sched(cb, ticks) {
   function fn() {
     if (--ticks)
-      process.nextTick(fn);
+      setImmediate(fn);
     else
       cb();
   }
-  process.nextTick(fn);
+  setImmediate(fn);
 }