diff --git a/benchmark/http_simple.js b/benchmark/http_simple.js index 4d9369c52a..28c215aaf5 100644 --- a/benchmark/http_simple.js +++ b/benchmark/http_simple.js @@ -1,7 +1,7 @@ path = require("path"); var puts = require("sys").puts; -var old = true; +var old = false; http = require(old ? "http_old" : 'http'); if (old) puts('old version'); @@ -56,6 +56,6 @@ http.createServer(function (req, res) { res.write(body, 'ascii'); res.close(); } else { - res.close(body, 'ascii'); + res.end(body, 'ascii'); } }).listen(8000); diff --git a/lib/fs.js b/lib/fs.js index 25ce376d5a..2157bc1b44 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -526,7 +526,7 @@ FileReadStream.prototype._read = function () { if (bytesRead === 0) { self.emit('end'); - self.forceClose(); + self.destroy(); return; } @@ -547,7 +547,18 @@ FileReadStream.prototype._read = function () { }; +var readStreamForceCloseWarning; + FileReadStream.prototype.forceClose = function (cb) { + if (!readStreamForceCloseWarning) { + readStreamForceCloseWarning = "FileReadStream.prototype.forceClose renamed to destroy()"; + sys.error(readStreamForceCloseWarning); + } + return this.destroy(cb); +} + + +FileReadStream.prototype.destroy = function (cb) { var self = this; this.readable = false; @@ -691,13 +702,35 @@ FileWriteStream.prototype.write = function(data, cb) { }; +var writeStreamCloseWarning; + FileWriteStream.prototype.close = function (cb) { + if (!writeStreamCloseWarning) { + writeStreamCloseWarning = "FileWriteStream.prototype.close renamed to end()"; + sys.error(writeStreamCloseWarning); + } + return this.end(cb); +} + + +FileWriteStream.prototype.end = function (cb) { this.writeable = false; this._queue.push([fs.close, cb]); this.flush(); }; +var writeStreamForceCloseWarning; + +FileWriteStream.prototype.forceClose = function (cb) { + if (!writeStreamForceCloseWarning) { + writeStreamForceCloseWarning = "FileWriteStream.prototype.forceClose renamed to destroy()"; + sys.error(writeStreamForceCloseWarning); + } + return this.destroy(cb); +} + + FileWriteStream.prototype.forceClose = function (cb) { this.writeable = false; fs.close(self.fd, function(err) { diff --git a/lib/http.js b/lib/http.js index 353c7daa79..d0ae3064c5 100644 --- a/lib/http.js +++ b/lib/http.js @@ -372,7 +372,17 @@ OutgoingMessage.prototype.finish = function () { throw new Error("finish() has been renamed to close()."); }; +var closeWarning; + OutgoingMessage.prototype.close = function (data, encoding) { + if (!closeWarning) { + closeWarning = "OutgoingMessage.prototype.close has been renamed to end()"; + sys.error(closeWarning); + } + return this.end(data, encoding); +}; + +OutgoingMessage.prototype.end = function (data, encoding) { if (data) this.write(data, encoding); if (this.chunkedEncoding) this._send("0\r\n\r\n"); // last chunk this.finished = true; @@ -436,19 +446,34 @@ sys.inherits(ClientRequest, OutgoingMessage); exports.ClientRequest = ClientRequest; ClientRequest.prototype.finish = function () { - throw new Error( "finish() has been renamed to close() and no longer takes " + throw new Error( "finish() has been renamed to end() and no longer takes " + "a response handler as an argument. Manually add a 'response' listener " + "to the request object." ); }; +var clientRequestCloseWarning; + ClientRequest.prototype.close = function () { + if (!clientRequestCloseWarning) { + clientRequestCloseWarning = "Warning: ClientRequest.prototype.close has been renamed to end()"; + sys.error(clientRequestCloseWarning); + } + if (arguments.length > 0) { + throw new Error( "ClientRequest.prototype.end does not take any arguments. " + + "Add a response listener manually to the request object." + ); + } + return this.end(); +}; + +ClientRequest.prototype.end = function () { if (arguments.length > 0) { - throw new Error( "ClientRequest.prototype.close does not take any arguments. " + throw new Error( "ClientRequest.prototype.end does not take any arguments. " + "Add a response listener manually to the request object." ); } - OutgoingMessage.prototype.close.call(this); + OutgoingMessage.prototype.end.call(this); }; @@ -509,7 +534,7 @@ function connectionListener (socket) { freeParser(parser); if (responses.length == 0) { - socket.close(); + socket.end(); } else { responses[responses.length-1].closeOnFinish = true; } @@ -525,7 +550,7 @@ function connectionListener (socket) { res.shouldKeepAlive = shouldKeepAlive; res.addListener('flush', function () { if (flushMessageQueue(socket, responses)) { - socket.close(); + socket.end(); } }); responses.push(res); @@ -582,7 +607,7 @@ function Client ( ) { parser.finish(); debug("self got end closing. readyState = " + self.readyState); - self.close(); + self.end(); }); self.addListener("close", function (e) { @@ -604,7 +629,7 @@ function Client ( ) { res.addListener('end', function ( ) { debug("request complete disconnecting. readyState = " + self.readyState); - self.close(); + self.end(); }); currentRequest.emit("response", res); @@ -697,7 +722,7 @@ exports.cat = function (url, encoding_, headers_) { req.addListener('response', function (res) { if (res.statusCode < 200 || res.statusCode >= 300) { if (callback) callback(res.statusCode); - client.close(); + client.end(); return; } res.setBodyEncoding(encoding); @@ -711,5 +736,5 @@ exports.cat = function (url, encoding_, headers_) { if (callback) callback(err); }); - req.close(); + req.end(); }; diff --git a/lib/net.js b/lib/net.js index 9968b66723..ff616eb964 100644 --- a/lib/net.js +++ b/lib/net.js @@ -136,7 +136,7 @@ var timeout = new (function () { remove(first); assert(first != peek(list)); first.emit('timeout'); - first.forceClose(new Error('idle timeout')); + first.destroy(new Error('idle timeout')); } } debug(msecs + ' list empty'); @@ -277,7 +277,7 @@ function initStream (self) { pool.used, pool.length - pool.used); } catch (e) { - self.forceClose(e); + self.destroy(e); return; } @@ -290,7 +290,7 @@ function initStream (self) { if (self._events && self._events['end']) self.emit('end'); if (self.onend) self.onend(); - if (!self.writable) self.forceClose(); + if (!self.writable) self.destroy(); } else if (bytesRead > 0) { timeout.active(self); @@ -485,7 +485,7 @@ Stream.prototype._writeOut = function (data, encoding) { try { bytesWritten = write(this.fd, buffer, off, len); } catch (e) { - this.forceClose(e); + this.destroy(e); return false; } @@ -563,7 +563,7 @@ function doConnect (socket, port, host) { try { connect(socket.fd, port, host); } catch (e) { - socket.forceClose(e); + socket.destroy(e); return; } @@ -589,7 +589,7 @@ function doConnect (socket, port, host) { socket._writeWatcher.callback = _doFlush; socket.emit('connect'); } else if (errno != EINPROGRESS) { - socket.forceClose(errnoException(errno, 'connect')); + socket.destroy(errnoException(errno, 'connect')); } }; } @@ -660,7 +660,18 @@ Stream.prototype.resume = function () { }; -Stream.prototype.forceClose = function (exception) { +var forceCloseWarning; + +Stream.prototype.forceClose = function (e) { + if (!forceCloseWarning) { + forceCloseWarning = "forceClose() has been renamed to destroy()"; + sys.error(forceCloseWarning); + } + return this.destroy(e); +}; + + +Stream.prototype.destroy = function (exception) { // pool is shared between sockets, so don't need to free it here. var self = this; @@ -701,18 +712,27 @@ Stream.prototype._shutdown = function () { try { shutdown(this.fd, 'write') } catch (e) { - this.forceClose(e); + this.destroy(e); return; } - if (!this.readable) this.forceClose(); + if (!this.readable) this.destroy(); } }; +var closeDepricationWarning; Stream.prototype.close = function (data, encoding) { - if (data) this.write(data, encoding); + if (!closeDepricationWarning) { + closeDepricationWarning = "Notification: Stream.prototype.close has been renamed to end()"; + sys.error(closeDepricationWarning); + } + return this.end(data, encoding); +}; + +Stream.prototype.end = function (data, encoding) { if (this.writable) { + if (data) this.write(data, encoding); if (this._writeQueueLast() != END_OF_FILE) { this._writeQueue.push(END_OF_FILE); this.flush(); diff --git a/test/pummel/test-http-client-reconnect-bug.js b/test/pummel/test-http-client-reconnect-bug.js index bdc709d356..2e963bb45a 100644 --- a/test/pummel/test-http-client-reconnect-bug.js +++ b/test/pummel/test-http-client-reconnect-bug.js @@ -8,7 +8,7 @@ var errorCount = 0; var eofCount = 0; var server = tcp.createServer(function(socket) { - socket.close(); + socket.end(); }); server.listen(PORT); @@ -28,7 +28,7 @@ var request = client.request("GET", "/", {"host": "localhost"}); request.addListener('response', function(response) { sys.puts("STATUS: " + response.statusCode); }); -request.close(); +request.end(); setTimeout(function () { server.close(); diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js index 5b71d4b00a..cc81dfc8f1 100644 --- a/test/pummel/test-keep-alive.js +++ b/test/pummel/test-keep-alive.js @@ -10,7 +10,7 @@ server = http.createServer(function (req, res) { "Content-Type": "text/plain", }); res.write(body); - res.close(); + res.end(); }); server.listen(PORT); diff --git a/test/pummel/test-tcp-many-clients.js b/test/pummel/test-tcp-many-clients.js index 1c27169af4..9ba72a74e3 100644 --- a/test/pummel/test-tcp-many-clients.js +++ b/test/pummel/test-tcp-many-clients.js @@ -18,7 +18,7 @@ var server = net.createServer(function (c) { total_connections++; print("#"); c.write(body); - c.close(); + c.end(); }); }); server.listen(PORT); @@ -41,7 +41,7 @@ function runClient (callback) { }); client.addListener("end", function () { - client.close(); + client.end(); }); client.addListener("error", function (e) { diff --git a/test/pummel/test-tcp-pause.js b/test/pummel/test-tcp-pause.js index adb6154401..de84c0ee67 100644 --- a/test/pummel/test-tcp-pause.js +++ b/test/pummel/test-tcp-pause.js @@ -5,7 +5,7 @@ N = 200; server = net.createServer(function (connection) { function write (j) { if (j >= N) { - connection.close(); + connection.end(); return; } setTimeout(function () { @@ -58,7 +58,7 @@ setTimeout(function () { client.addListener("end", function () { server.close(); - client.close(); + client.end(); }); process.addListener("exit", function () { diff --git a/test/pummel/test-tcp-pingpong-delay.js b/test/pummel/test-tcp-pingpong-delay.js index a2015c373e..58546745f6 100644 --- a/test/pummel/test-tcp-pingpong-delay.js +++ b/test/pummel/test-tcp-pingpong-delay.js @@ -8,7 +8,7 @@ function pingPongTest (port, host, on_complete) { var N = 100; var DELAY = 1; var count = 0; - var client_closed = false; + var client_ended = false; var server = net.createServer(function (socket) { socket.setEncoding("utf8"); @@ -32,11 +32,11 @@ function pingPongTest (port, host, on_complete) { socket.addListener("end", function () { puts("server-side socket EOF"); assert.equal("writeOnly", socket.readyState); - socket.close(); + socket.end(); }); socket.addListener("close", function (had_error) { - puts("server-side socket close"); + puts("server-side socket.end"); assert.equal(false, had_error); assert.equal("closed", socket.readyState); socket.server.close(); @@ -64,8 +64,8 @@ function pingPongTest (port, host, on_complete) { client.write("PING"); } else { puts("closing client"); - client.close(); - client_closed = true; + client.end(); + client_ended = true; } }, DELAY); }); @@ -76,9 +76,9 @@ function pingPongTest (port, host, on_complete) { }); client.addListener("close", function () { - puts("client close"); + puts("client.end"); assert.equal(N+1, count); - assert.equal(true, client_closed); + assert.ok(client_ended); if (on_complete) on_complete(); tests_run += 1; }); diff --git a/test/pummel/test-tcp-pingpong.js b/test/pummel/test-tcp-pingpong.js index c9a66ffc91..d96e398aee 100644 --- a/test/pummel/test-tcp-pingpong.js +++ b/test/pummel/test-tcp-pingpong.js @@ -33,7 +33,7 @@ function pingPongTest (port, host, on_complete) { socket.addListener("end", function () { assert.equal("writeOnly", socket.readyState); - socket.close(); + socket.end(); }); socket.addListener("close", function (had_error) { @@ -71,7 +71,7 @@ function pingPongTest (port, host, on_complete) { } else { sent_final_ping = true; client.write("PING"); - client.close(); + client.end(); } }); diff --git a/test/pummel/test-tcp-throttle.js b/test/pummel/test-tcp-throttle.js index 029d364572..8da7239d53 100644 --- a/test/pummel/test-tcp-throttle.js +++ b/test/pummel/test-tcp-throttle.js @@ -13,7 +13,7 @@ puts("start server on port " + PORT); server = net.createServer(function (connection) { connection.addListener("connect", function () { assert.equal(false, connection.write(body)); - connection.close(); + connection.end(); }); }); server.listen(PORT); @@ -46,7 +46,7 @@ client.addListener("data", function (d) { client.addListener("end", function () { server.close(); - client.close(); + client.end(); }); process.addListener("exit", function () { diff --git a/test/pummel/test-tcp-timeout.js b/test/pummel/test-tcp-timeout.js index fe82ab3d3f..4279daf5ce 100644 --- a/test/pummel/test-tcp-timeout.js +++ b/test/pummel/test-tcp-timeout.js @@ -20,7 +20,7 @@ var echo_server = net.createServer(function (socket) { }); socket.addListener("end", function () { - socket.close(); + socket.end(); }); }); @@ -58,7 +58,7 @@ client.addListener("timeout", function () { client.addListener("end", function () { puts("client end"); - client.close(); + client.end(); }); client.addListener("close", function () { diff --git a/test/pummel/test-tcp-tls.js b/test/pummel/test-tcp-tls.js index 55612d6965..d156b936c7 100644 --- a/test/pummel/test-tcp-tls.js +++ b/test/pummel/test-tcp-tls.js @@ -37,7 +37,7 @@ function tlsTest (port, host, caPem, keyPem, certPem) { socket.addListener("end", function () { assert.equal("writeOnly", socket.readyState); - socket.close(); + socket.end(); }); socket.addListener("close", function (had_error) { @@ -83,7 +83,7 @@ function tlsTest (port, host, caPem, keyPem, certPem) { } else { sent_final_ping = true; client.write("PING"); - client.close(); + client.end(); } }); diff --git a/test/simple/test-child-process-ipc.js b/test/simple/test-child-process-ipc.js index ca28462aa7..3b9881262e 100644 --- a/test/simple/test-child-process-ipc.js +++ b/test/simple/test-child-process-ipc.js @@ -26,7 +26,7 @@ child.stdout.addListener("data", function (data){ } else { assert.equal("echo me\r\n", data); gotEcho = true; - child.stdin.close(); + child.stdin.end(); } }); diff --git a/test/simple/test-child-process-stdin.js b/test/simple/test-child-process-stdin.js index d60740cb71..6521f43768 100644 --- a/test/simple/test-child-process-stdin.js +++ b/test/simple/test-child-process-stdin.js @@ -6,7 +6,7 @@ var cat = spawn("cat"); cat.stdin.write("hello"); cat.stdin.write(" "); cat.stdin.write("world"); -cat.stdin.close(); +cat.stdin.end(); var response = ""; var exitStatus = -1; diff --git a/test/simple/test-file-read-stream.js b/test/simple/test-file-read-stream.js index de8ff63259..a7fa8b69ab 100644 --- a/test/simple/test-file-read-stream.js +++ b/test/simple/test-file-read-stream.js @@ -10,7 +10,7 @@ var open: -1, end: -1, close: -1, - forceClose: -1 + destroy: -1 }, paused = false, @@ -51,9 +51,9 @@ file }); var file2 = fs.createReadStream(fn); -file2.forceClose(function(err) { +file2.destroy(function(err) { assert.ok(!err); - callbacks.forceClose++; + callbacks.destroy++; }); process.addListener('exit', function() { diff --git a/test/simple/test-file-write-stream.js b/test/simple/test-file-write-stream.js index df045998cd..51beb8c8fe 100644 --- a/test/simple/test-file-write-stream.js +++ b/test/simple/test-file-write-stream.js @@ -12,7 +12,7 @@ var open: -1, drain: -2, close: -1, - closeCb: -1, + endCb: -1, write: -11, }; @@ -31,9 +31,9 @@ file file.write(EXPECTED); } else if (callbacks.drain == 0) { assert.equal(EXPECTED+EXPECTED, fs.readFileSync(fn)); - file.close(function(err) { + file.end(function(err) { assert.ok(!err); - callbacks.closeCb++; + callbacks.endCb++; }); } }) diff --git a/test/simple/test-http-1.0.js b/test/simple/test-http-1.0.js index 3a8cd0ebb8..248c7fc502 100644 --- a/test/simple/test-http-1.0.js +++ b/test/simple/test-http-1.0.js @@ -8,7 +8,7 @@ var client_got_eof = false; var server = http.createServer(function (req, res) { res.writeHead(200, {"Content-Type": "text/plain"}); - res.close(body); + res.end(body); }) server.listen(PORT); @@ -27,7 +27,7 @@ c.addListener("data", function (chunk) { c.addListener("end", function () { client_got_eof = true; - c.close(); + c.end(); server.close(); }); diff --git a/test/simple/test-http-cat.js b/test/simple/test-http-cat.js index f270ca9278..179298e6aa 100644 --- a/test/simple/test-http-cat.js +++ b/test/simple/test-http-cat.js @@ -8,7 +8,7 @@ var server = http.createServer(function (req, res) { ["Content-Length", body.length], ["Content-Type", "text/plain"] ]); - res.close(body); + res.end(body); }); server.listen(PORT); diff --git a/test/simple/test-http-chunked.js b/test/simple/test-http-chunked.js index bb065de938..b1168ebb61 100644 --- a/test/simple/test-http-chunked.js +++ b/test/simple/test-http-chunked.js @@ -5,7 +5,7 @@ var UTF8_STRING = "南越国是前203年至前111年存在于岭南地区的一 var server = http.createServer(function(req, res) { res.writeHead(200, {"Content-Type": "text/plain; charset=utf8"}); - res.close(UTF8_STRING, 'utf8'); + res.end(UTF8_STRING, 'utf8'); }); server.listen(PORT); diff --git a/test/simple/test-http-client-race.js b/test/simple/test-http-client-race.js index b9b0df4848..e66964885c 100644 --- a/test/simple/test-http-client-race.js +++ b/test/simple/test-http-client-race.js @@ -10,7 +10,7 @@ var server = http.createServer(function (req, res) { res.writeHead(200, { "Content-Type": "text/plain" , "Content-Length": body.length }); - res.close(body); + res.end(body); }); server.listen(PORT); @@ -34,10 +34,10 @@ req1.addListener('response', function (res1) { res2.addListener('data', function (chunk) { body2 += chunk; }); res2.addListener('end', function () { server.close(); }); }); - req2.close(); + req2.end(); }); }); -req1.close(); +req1.end(); process.addListener("exit", function () { assert.equal(body1_s, body1); diff --git a/test/simple/test-http-client-upload.js b/test/simple/test-http-client-upload.js index b4c0f61acb..ce7887a7ce 100644 --- a/test/simple/test-http-client-upload.js +++ b/test/simple/test-http-client-upload.js @@ -19,7 +19,7 @@ var server = http.createServer(function(req, res) { puts("request complete from server"); res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('hello\n'); - res.close(); + res.end(); }); }); server.listen(PORT); @@ -42,7 +42,7 @@ req.addListener('response', function(res) { server.close(); }); }); -req.close(); +req.end(); process.addListener("exit", function () { assert.equal("1\n2\n3\n", sent_body); diff --git a/test/simple/test-http-malformed-request.js b/test/simple/test-http-malformed-request.js index 47bcfca324..e93fba9037 100644 --- a/test/simple/test-http-malformed-request.js +++ b/test/simple/test-http-malformed-request.js @@ -14,7 +14,7 @@ var s = http.createServer(function (req, res) { res.writeHead(200, {"Content-Type": "text/plain"}); res.write("Hello World"); - res.close(); + res.end(); if (++nrequests_completed == nrequests_expected) s.close(); }); @@ -23,7 +23,7 @@ s.listen(PORT); var c = net.createConnection(PORT); c.addListener("connect", function () { c.write("GET /hello?foo=%99bar HTTP/1.1\r\n\r\n"); - c.close(); + c.end(); }); // TODO add more! diff --git a/test/simple/test-http-proxy.js b/test/simple/test-http-proxy.js index 348851d6ba..ffaec764eb 100644 --- a/test/simple/test-http-proxy.js +++ b/test/simple/test-http-proxy.js @@ -9,7 +9,7 @@ var backend = http.createServer(function (req, res) { debug("backend request"); res.writeHead(200, {"content-type": "text/plain"}); res.write("hello world\n"); - res.close(); + res.end(); }); debug("listen backend") backend.listen(BACKEND_PORT); @@ -24,11 +24,11 @@ var proxy = http.createServer(function (req, res) { res.write(chunk); }); proxy_res.addListener("end", function() { - res.close(); + res.end(); debug("proxy res"); }); }); - proxy_req.close(); + proxy_req.end(); }); debug("listen proxy") proxy.listen(PROXY_PORT); @@ -54,7 +54,7 @@ function startReq () { debug("closed both"); }); }); - req.close(); + req.end(); } proxy.addListener('listening', startReq); diff --git a/test/simple/test-http-server.js b/test/simple/test-http-server.js index c7deeb8baf..ec249570ef 100644 --- a/test/simple/test-http-server.js +++ b/test/simple/test-http-server.js @@ -38,7 +38,7 @@ http.createServer(function (req, res) { setTimeout(function () { res.writeHead(200, {"Content-Type": "text/plain"}); res.write(url.parse(req.url).pathname); - res.close(); + res.end(); }, 1); }).listen(PORT); @@ -63,7 +63,7 @@ c.addListener("data", function (chunk) { if (requests_sent == 2) { c.write("GET / HTTP/1.1\r\nX-X: foo\r\n\r\n" +"GET / HTTP/1.1\r\nX-X: bar\r\n\r\n"); - c.close(); + c.end(); assert.equal(c.readyState, "readOnly"); requests_sent += 2; } diff --git a/test/simple/test-http-tls.js b/test/simple/test-http-tls.js index 0784829421..92181332af 100644 --- a/test/simple/test-http-tls.js +++ b/test/simple/test-http-tls.js @@ -54,7 +54,7 @@ var http_server=http.createServer(function (req, res) { req.addListener('end', function () { res.writeHead(200, {"Content-Type": "text/plain"}); res.write("The path was " + url.parse(req.url).pathname); - res.close(); + res.end(); responses_sent += 1; }); @@ -78,7 +78,7 @@ req.addListener('response', function (res) { res.addListener('data', function (chunk) { body0 += chunk; }); debug("Got /hello response"); }); -req.close(); +req.end(); setTimeout(function () { req = client.request("POST", "/world"); @@ -94,7 +94,7 @@ setTimeout(function () { res.addListener('data', function (chunk) { body1 += chunk; }); debug("Got /world response"); }); - req.close(); + req.end(); }, 1); process.addListener("exit", function () { diff --git a/test/simple/test-http-wget.js b/test/simple/test-http-wget.js index 1d7f341263..47e215e1dd 100644 --- a/test/simple/test-http-wget.js +++ b/test/simple/test-http-wget.js @@ -25,7 +25,7 @@ var server = http.createServer(function (req, res) { res.writeHead(200, {"Content-Type": "text/plain"}); res.write("hello "); res.write("world\n"); - res.close(); + res.end(); }) server.listen(PORT); @@ -46,7 +46,7 @@ c.addListener("data", function (chunk) { c.addListener("end", function () { client_got_eof = true; puts('got end'); - c.close(); + c.end(); }); c.addListener("close", function () { diff --git a/test/simple/test-http.js b/test/simple/test-http.js index c59927763a..f1da37c7ca 100644 --- a/test/simple/test-http.js +++ b/test/simple/test-http.js @@ -29,7 +29,7 @@ http.createServer(function (req, res) { req.addListener('end', function () { res.writeHead(200, {"Content-Type": "text/plain"}); res.write("The path was " + url.parse(req.url).pathname); - res.close(); + res.end(); responses_sent += 1; }); @@ -45,7 +45,7 @@ req.addListener('response', function (res) { res.addListener('data', function (chunk) { body0 += chunk; }); debug("Got /hello response"); }); -req.close(); +req.end(); setTimeout(function () { req = client.request("POST", "/world"); @@ -56,7 +56,7 @@ setTimeout(function () { res.addListener('data', function (chunk) { body1 += chunk; }); debug("Got /world response"); }); - req.close(); + req.end(); }, 1); process.addListener("exit", function () { diff --git a/test/simple/test-net-pingpong.js b/test/simple/test-net-pingpong.js index ed8cfebf87..cf977dc248 100644 --- a/test/simple/test-net-pingpong.js +++ b/test/simple/test-net-pingpong.js @@ -30,7 +30,7 @@ function pingPongTest (port, host) { socket.addListener("end", function () { assert.equal(true, socket.writable); assert.equal(false, socket.readable); - socket.close(); + socket.end(); }); socket.addListener("error", function (e) { @@ -38,7 +38,7 @@ function pingPongTest (port, host) { }); socket.addListener("close", function () { - puts('server socket closed'); + puts('server socket.endd'); assert.equal(false, socket.writable); assert.equal(false, socket.readable); socket.server.close(); @@ -77,12 +77,12 @@ function pingPongTest (port, host) { } else { sent_final_ping = true; client.write("PING"); - client.close(); + client.end(); } }); client.addListener("close", function () { - puts('client closed'); + puts('client.endd'); assert.equal(N+1, count); assert.equal(true, sent_final_ping); tests_run += 1; diff --git a/test/simple/test-remote-module-loading.js b/test/simple/test-remote-module-loading.js index 0a2af87e08..00a0974dcc 100644 --- a/test/simple/test-remote-module-loading.js +++ b/test/simple/test-remote-module-loading.js @@ -12,7 +12,7 @@ var server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Type': 'text/javascript'}); res.write(body); - res.close(); + res.end(); }); server.listen(PORT); diff --git a/test/simple/test-tcp-binary.js b/test/simple/test-tcp-binary.js index e1d85542c3..9dc347a429 100644 --- a/test/simple/test-tcp-binary.js +++ b/test/simple/test-tcp-binary.js @@ -25,7 +25,7 @@ var echoServer = tcp.createServer(function (connection) { connection.write(chunk, "binary"); }); connection.addListener("end", function () { - connection.close(); + connection.end(); }); }); echoServer.listen(PORT); @@ -42,7 +42,7 @@ c.addListener("data", function (chunk) { c.write(String.fromCharCode(j), "binary"); j++; } else { - c.close(); + c.end(); } recv += chunk; }); diff --git a/test/simple/test-tcp-reconnect.js b/test/simple/test-tcp-reconnect.js index 66d93e30d6..143c4ac8b4 100644 --- a/test/simple/test-tcp-reconnect.js +++ b/test/simple/test-tcp-reconnect.js @@ -12,7 +12,7 @@ var server = net.createServer(function (socket) { }); socket.addListener("end", function () { - socket.close(); + socket.end(); }); socket.addListener("close", function (had_error) { @@ -37,7 +37,7 @@ server.addListener('listening', function () { client_recv_count += 1; puts("client_recv_count " + client_recv_count); assert.equal("hello\r\n", chunk); - client.close(); + client.end(); }); client.addListener("close", function (had_error) {