summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-outgoing-writableFinished.js
diff options
context:
space:
mode:
authorRobert Nagy <ronagy@icloud.com>2019-07-14 18:13:08 +0200
committerRich Trott <rtrott@gmail.com>2019-07-16 10:26:08 -0700
commit7032e59bb550adcb448b2d24877921e7f97e7399 (patch)
tree0d01f95a35123a7ad9d90f9740e55fc6aa258bbf /test/parallel/test-http-outgoing-writableFinished.js
parent462f43824f6af577bde27da76d9f33365eddcfe7 (diff)
downloadandroid-node-v8-7032e59bb550adcb448b2d24877921e7f97e7399.tar.gz
android-node-v8-7032e59bb550adcb448b2d24877921e7f97e7399.tar.bz2
android-node-v8-7032e59bb550adcb448b2d24877921e7f97e7399.zip
http: add response.writableFinished
response.writableFinished is true if all data has been flushed to the underlying system. PR-URL: https://github.com/nodejs/node/pull/28681 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'test/parallel/test-http-outgoing-writableFinished.js')
-rw-r--r--test/parallel/test-http-outgoing-writableFinished.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/parallel/test-http-outgoing-writableFinished.js b/test/parallel/test-http-outgoing-writableFinished.js
new file mode 100644
index 0000000000..6f84d91e71
--- /dev/null
+++ b/test/parallel/test-http-outgoing-writableFinished.js
@@ -0,0 +1,32 @@
+'use strict';
+const common = require('../common');
+const assert = require('assert');
+const http = require('http');
+
+const server = http.createServer(common.mustCall(function(req, res) {
+ assert.strictEqual(res.writableFinished, false);
+ res
+ .on('finish', common.mustCall(() => {
+ assert.strictEqual(res.writableFinished, true);
+ server.close();
+ }))
+ .end();
+}));
+
+server.listen(0);
+
+server.on('listening', common.mustCall(function() {
+ const clientRequest = http.request({
+ port: server.address().port,
+ method: 'GET',
+ path: '/'
+ });
+
+ assert.strictEqual(clientRequest.writableFinished, false);
+ clientRequest
+ .on('finish', common.mustCall(() => {
+ assert.strictEqual(clientRequest.writableFinished, true);
+ }))
+ .end();
+ assert.strictEqual(clientRequest.writableFinished, false);
+}));