Permalink
Browse files

test updates for streams2

  • Loading branch information...
1 parent ac65802 commit 27d69b8e3a0dfdd268b79b09f97d11e5126843b4 @isaacs committed Dec 13, 2012
View
11 test/simple/test-domain-http-server.js
@@ -39,7 +39,7 @@ var server = http.createServer(function(req, res) {
dom.on('error', function(er) {
serverCaught++;
- console.log('server error', er);
+ console.log('horray! got a server error', er);
// try to send a 500. If that fails, oh well.
res.writeHead(500, {'content-type':'text/plain'});
res.end(er.stack || er.message || 'Unknown error');
@@ -82,12 +82,7 @@ function next() {
dom.on('error', function(er) {
clientCaught++;
console.log('client error', er);
- // kill everything.
- dom.dispose();
- });
-
- dom.on('dispose', function() {
- disposeEmit += 1;
+ req.socket.destroy();
});
var req = http.get({ host: 'localhost', port: common.PORT, path: p });
@@ -107,6 +102,7 @@ function next() {
d += c;
});
res.on('end', function() {
+ console.error('trying to parse json', d);
d = JSON.parse(d);
console.log('json!', d);
});
@@ -117,6 +113,5 @@ function next() {
process.on('exit', function() {
assert.equal(serverCaught, 2);
assert.equal(clientCaught, 2);
- assert.equal(disposeEmit, 2);
console.log('ok');
});
View
10 test/simple/test-http-agent.js
@@ -40,10 +40,14 @@ server.listen(common.PORT, function() {
setTimeout(function() {
for (var j = 0; j < M; j++) {
http.get({ port: common.PORT, path: '/' }, function(res) {
- console.log(res.statusCode);
- if (++responses == N * M) server.close();
+ console.log('%d %d', responses, res.statusCode);
+ if (++responses == N * M) {
+ console.error('Received all responses, closing server');
+ server.close();
+ }
+ res.resume();
}).on('error', function(e) {
- console.log(e.message);
+ console.log('Error!', e);
process.exit(1);
});
}
View
1 test/simple/test-http-date-header.js
@@ -49,6 +49,7 @@ server.addListener('listening', function() {
server.close();
process.exit();
});
+ res.resume();
});
req.end();
});
View
1 test/simple/test-http-default-encoding.js
@@ -50,6 +50,7 @@ server.listen(common.PORT, function() {
method: 'POST'
}, function(res) {
console.log(res.statusCode);
+ res.resume();
}).on('error', function(e) {
console.log(e.message);
process.exit(1);
View
1 test/simple/test-http-header-read.js
@@ -50,5 +50,6 @@ function runTest() {
response.on('end', function() {
s.close();
});
+ response.resume();
});
}
View
6 test/simple/test-http-host-headers.js
@@ -57,13 +57,14 @@ function testHttp() {
var counter = 0;
- function cb() {
+ function cb(res) {
counter--;
console.log('back from http request. counter = ' + counter);
if (counter === 0) {
httpServer.close();
testHttps();
}
+ res.resume();
}
httpServer.listen(common.PORT, function(er) {
@@ -124,13 +125,14 @@ function testHttps() {
var counter = 0;
- function cb() {
+ function cb(res) {
counter--;
console.log('back from https request. counter = ' + counter);
if (counter === 0) {
httpsServer.close();
console.log('ok');
}
+ res.resume();
}
httpsServer.listen(common.PORT, function(er) {
View
7 test/simple/test-http-keep-alive-close-on-header.js
@@ -44,8 +44,9 @@ server.listen(common.PORT, function() {
headers: headers,
port: common.PORT,
agent: agent
- }, function() {
+ }, function(res) {
assert.equal(1, agent.sockets['localhost:' + common.PORT].length);
+ res.resume();
});
request.on('socket', function(s) {
s.on('connect', function() {
@@ -60,8 +61,9 @@ server.listen(common.PORT, function() {
headers: headers,
port: common.PORT,
agent: agent
- }, function() {
+ }, function(res) {
assert.equal(1, agent.sockets['localhost:' + common.PORT].length);
+ res.resume();
});
request.on('socket', function(s) {
s.on('connect', function() {
@@ -80,6 +82,7 @@ server.listen(common.PORT, function() {
assert.equal(1, agent.sockets['localhost:' + common.PORT].length);
server.close();
});
+ response.resume();
});
request.on('socket', function(s) {
s.on('connect', function() {
View
3 test/simple/test-http-keep-alive.js
@@ -42,13 +42,15 @@ server.listen(common.PORT, function() {
}, function(response) {
assert.equal(agent.sockets[name].length, 1);
assert.equal(agent.requests[name].length, 2);
+ response.resume();
});
http.get({
path: '/', headers: headers, port: common.PORT, agent: agent
}, function(response) {
assert.equal(agent.sockets[name].length, 1);
assert.equal(agent.requests[name].length, 1);
+ response.resume();
});
http.get({
@@ -59,6 +61,7 @@ server.listen(common.PORT, function() {
assert(!agent.requests.hasOwnProperty(name));
server.close();
});
+ response.resume();
});
});
View
1 test/simple/test-http-many-keep-alive-connections.js
@@ -55,6 +55,7 @@ server.listen(common.PORT, function() {
server.close();
}
});
+ res.resume();
}).on('error', function(e) {
console.log(e.message);
process.exit(1);
View
1 test/simple/test-http-parser-free.js
@@ -44,6 +44,7 @@ server.listen(common.PORT, function() {
if (++responses === N) {
server.close();
}
+ res.resume();
});
})(i);
}
View
1 test/simple/test-http-request-end-twice.js
@@ -36,6 +36,7 @@ server.listen(common.PORT, function() {
assert.ok(!req.end());
server.close();
});
+ res.resume();
});
});
View
1 test/simple/test-http-request-end.js
@@ -47,6 +47,7 @@ server.listen(common.PORT, function() {
method: 'POST'
}, function(res) {
console.log(res.statusCode);
+ res.resume();
}).on('error', function(e) {
console.log(e.message);
process.exit(1);
View
6 test/simple/test-http-res-write-end-dont-take-array.js
@@ -53,11 +53,13 @@ var server = http.createServer(function(req, res) {
server.listen(common.PORT, function() {
// just make a request, other tests handle responses
- http.get({port: common.PORT}, function() {
+ http.get({port: common.PORT}, function(res) {
+ res.resume();
// lazy serial test, becuase we can only call end once per request
test += 1;
// do it again to test .end(Buffer);
- http.get({port: common.PORT}, function() {
+ http.get({port: common.PORT}, function(res) {
+ res.resume();
server.close();
});
});
View
1 test/simple/test-http-response-readable.js
@@ -35,6 +35,7 @@ testServer.listen(common.PORT, function() {
assert.equal(res.readable, false, 'res.readable set to false after end');
testServer.close();
});
+ res.resume();
});
});
View
1 test/simple/test-http-set-trailers.js
@@ -106,6 +106,7 @@ server.on('listening', function() {
process.exit();
}
});
+ res.resume();
});
outstanding_reqs++;
});
View
1 test/simple/test-http-status-code.js
@@ -59,6 +59,7 @@ function nextTest() {
testIdx += 1;
nextTest();
});
+ response.resume();
});
}
View
2 test/simple/test-http-timeout.js
@@ -55,6 +55,8 @@ server.listen(port, function() {
server.close();
}
})
+
+ res.resume();
});
req.setTimeout(1000, callback);
View
1 test/simple/test-https-agent.js
@@ -54,6 +54,7 @@ server.listen(common.PORT, function() {
port: common.PORT,
rejectUnauthorized: false
}, function(res) {
+ res.resume();
console.log(res.statusCode);
if (++responses == N * M) server.close();
}).on('error', function(e) {
View
2 test/simple/test-https-socket-options.js
@@ -55,6 +55,7 @@ server_http.listen(common.PORT, function() {
rejectUnauthorized: false
}, function(res) {
server_http.close();
+ res.resume();
});
// These methods should exist on the request and get passed down to the socket
req.setNoDelay(true);
@@ -77,6 +78,7 @@ server_https.listen(common.PORT+1, function() {
rejectUnauthorized: false
}, function(res) {
server_https.close();
+ res.resume();
});
// These methods should exist on the request and get passed down to the socket
req.setNoDelay(true);
View
1 test/simple/test-https-strict.js
@@ -170,6 +170,7 @@ function makeReq(path, port, error, host, ca) {
server2.close();
server3.close();
}
+ res.resume();
})
}
View
1 test/simple/test-regress-GH-877.js
@@ -48,6 +48,7 @@ server.listen(common.PORT, '127.0.0.1', function() {
if (++responses == N) {
server.close();
}
+ res.resume();
});
assert.equal(req.agent, agent);

0 comments on commit 27d69b8

Please sign in to comment.