summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-outgoing-end-multiple.js
diff options
context:
space:
mode:
authorRobert Nagy <ronagy@icloud.com>2019-07-14 22:11:06 +0200
committerRich Trott <rtrott@gmail.com>2019-08-20 08:47:19 -0700
commitdb706da235d80e5dadaab64328bfad9cb313be39 (patch)
tree58182b1324b6fe3e370bca7a377f99cff73903bf /test/parallel/test-http-outgoing-end-multiple.js
parent85898e0aca26cee2e68aea9ba384e23cd4457849 (diff)
downloadandroid-node-v8-db706da235d80e5dadaab64328bfad9cb313be39.tar.gz
android-node-v8-db706da235d80e5dadaab64328bfad9cb313be39.tar.bz2
android-node-v8-db706da235d80e5dadaab64328bfad9cb313be39.zip
stream: disallow stream methods on finished stream
Invoke callback with ERR_STREAM_ALREADY_FINISHED error if `end()` is called on a finished stream. PR-URL: https://github.com/nodejs/node/pull/28687 Refs: https://github.com/nodejs/node/issues/28667 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@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-end-multiple.js')
-rw-r--r--test/parallel/test-http-outgoing-end-multiple.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/parallel/test-http-outgoing-end-multiple.js b/test/parallel/test-http-outgoing-end-multiple.js
new file mode 100644
index 0000000000..7c43e1f59d
--- /dev/null
+++ b/test/parallel/test-http-outgoing-end-multiple.js
@@ -0,0 +1,27 @@
+'use strict';
+const common = require('../common');
+const assert = require('assert');
+const http = require('http');
+
+const server = http.createServer(common.mustCall(function(req, res) {
+ res.end('testing ended state', common.mustCall());
+ res.end(common.mustCall());
+ res.on('finish', common.mustCall(() => {
+ res.end(common.mustCall((err) => {
+ assert.strictEqual(err.code, 'ERR_STREAM_ALREADY_FINISHED');
+ server.close();
+ }));
+ }));
+}));
+
+server.listen(0);
+
+server.on('listening', common.mustCall(function() {
+ http
+ .request({
+ port: server.address().port,
+ method: 'GET',
+ path: '/'
+ })
+ .end();
+}));