summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-set-timeout-server.js
diff options
context:
space:
mode:
authorEvan Lucas <evanlucas@me.com>2015-05-13 21:25:57 -0500
committerRoman Reiss <me@silverwind.io>2015-05-16 07:17:41 +0200
commitd4726cde57856896c560820b89eae0bc08621034 (patch)
tree01e5ec875240d6e0fb9a7b4e8cfba309dd271a44 /test/parallel/test-http-set-timeout-server.js
parentc7fb91dc1310f9454d4aa8091bcc6d305322a72f (diff)
downloadandroid-node-v8-d4726cde57856896c560820b89eae0bc08621034.tar.gz
android-node-v8-d4726cde57856896c560820b89eae0bc08621034.tar.bz2
android-node-v8-d4726cde57856896c560820b89eae0bc08621034.zip
http,net,tls: return this from setTimeout methods
Modifies the setTimeout methods for the following prototypes: - http.ClientRequest - http.IncomingMessage - http.OutgoingMessage - http.Server - https.Server - net.Socket - tls.TLSSocket Previously, the above functions returned undefined. They now return `this`. This is useful for chaining function calls. PR-URL: https://github.com/nodejs/io.js/pull/1699 Reviewed-By: Roman Reiss <me@silverwind.io>
Diffstat (limited to 'test/parallel/test-http-set-timeout-server.js')
-rw-r--r--test/parallel/test-http-set-timeout-server.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/test/parallel/test-http-set-timeout-server.js b/test/parallel/test-http-set-timeout-server.js
index ccad6f1f3a..caefc03832 100644
--- a/test/parallel/test-http-set-timeout-server.js
+++ b/test/parallel/test-http-set-timeout-server.js
@@ -29,12 +29,13 @@ test(function serverTimeout(cb) {
// just do nothing, we should get a timeout event.
});
server.listen(common.PORT);
- server.setTimeout(50, function(socket) {
+ var s = server.setTimeout(50, function(socket) {
caughtTimeout = true;
socket.destroy();
server.close();
cb();
});
+ assert.ok(s instanceof http.Server);
http.get({ port: common.PORT }).on('error', function() {});
});
@@ -45,12 +46,13 @@ test(function serverRequestTimeout(cb) {
});
var server = http.createServer(function(req, res) {
// just do nothing, we should get a timeout event.
- req.setTimeout(50, function() {
+ var s = req.setTimeout(50, function() {
caughtTimeout = true;
req.socket.destroy();
server.close();
cb();
});
+ assert.ok(s instanceof http.IncomingMessage);
});
server.listen(common.PORT);
var req = http.request({ port: common.PORT, method: 'POST' });
@@ -66,12 +68,13 @@ test(function serverResponseTimeout(cb) {
});
var server = http.createServer(function(req, res) {
// just do nothing, we should get a timeout event.
- res.setTimeout(50, function() {
+ var s = res.setTimeout(50, function() {
caughtTimeout = true;
res.socket.destroy();
server.close();
cb();
});
+ assert.ok(s instanceof http.OutgoingMessage);
});
server.listen(common.PORT);
http.get({ port: common.PORT }).on('error', function() {});
@@ -86,9 +89,10 @@ test(function serverRequestNotTimeoutAfterEnd(cb) {
});
var server = http.createServer(function(req, res) {
// just do nothing, we should get a timeout event.
- req.setTimeout(50, function(socket) {
+ var s = req.setTimeout(50, function(socket) {
caughtTimeoutOnRequest = true;
});
+ assert.ok(s instanceof http.IncomingMessage);
res.on('timeout', function(socket) {
caughtTimeoutOnResponse = true;
});
@@ -108,9 +112,10 @@ test(function serverResponseTimeoutWithPipeline(cb) {
assert.equal(caughtTimeout, '/2');
});
var server = http.createServer(function(req, res) {
- res.setTimeout(50, function() {
+ var s = res.setTimeout(50, function() {
caughtTimeout += req.url;
});
+ assert.ok(s instanceof http.OutgoingMessage);
if (req.url === '/1') res.end();
});
server.on('timeout', function(socket) {
@@ -144,12 +149,13 @@ test(function idleTimeout(cb) {
});
res.end();
});
- server.setTimeout(50, function(socket) {
+ var s = server.setTimeout(50, function(socket) {
caughtTimeoutOnServer = true;
socket.destroy();
server.close();
cb();
});
+ assert.ok(s instanceof http.Server);
server.listen(common.PORT);
var c = net.connect({ port: common.PORT, allowHalfOpen: true }, function() {
c.write('GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n');