diff options
author | Anatoli Papirovski <apapirovski@mac.com> | 2017-09-14 14:02:54 -0400 |
---|---|---|
committer | Matteo Collina <hello@matteocollina.com> | 2017-09-18 12:28:24 +0200 |
commit | a4e923f5c13b80bf43ecfca4e9be483535011dbe (patch) | |
tree | e22eac5067c7dfc638a062cfe14d7e25c4a401b5 /test/parallel/test-http2-compat-serverresponse-end.js | |
parent | bd8575287141bf52ad90d522e40998c52e8403aa (diff) | |
download | android-node-v8-a4e923f5c13b80bf43ecfca4e9be483535011dbe.tar.gz android-node-v8-a4e923f5c13b80bf43ecfca4e9be483535011dbe.tar.bz2 android-node-v8-a4e923f5c13b80bf43ecfca4e9be483535011dbe.zip |
http2: fix subsequent end calls to not throw
Calling Http2ServerResponse.end multiple times should never
cause the code to throw an error, subsequent calls should
instead return false. Fix behaviour to match http1.
Fixes: https://github.com/nodejs/node/issues/15385
PR-URL: https://github.com/nodejs/node/pull/15414
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test/parallel/test-http2-compat-serverresponse-end.js')
-rw-r--r-- | test/parallel/test-http2-compat-serverresponse-end.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/test/parallel/test-http2-compat-serverresponse-end.js b/test/parallel/test-http2-compat-serverresponse-end.js index 6c07f6d83e..92a0fab4e0 100644 --- a/test/parallel/test-http2-compat-serverresponse-end.js +++ b/test/parallel/test-http2-compat-serverresponse-end.js @@ -4,7 +4,7 @@ const { mustCall, mustNotCall, hasCrypto, skip } = require('../common'); if (!hasCrypto) skip('missing crypto'); -const { strictEqual } = require('assert'); +const { doesNotThrow, strictEqual } = require('assert'); const { createServer, connect, @@ -19,6 +19,9 @@ const { // but may be invoked repeatedly without throwing errors. const server = createServer(mustCall((request, response) => { strictEqual(response.closed, false); + response.on('finish', mustCall(() => process.nextTick( + mustCall(() => doesNotThrow(() => response.end('test', mustNotCall()))) + ))); response.end(mustCall(() => { server.close(); })); |