forked from nodejs/node
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http2: make compat writeHead not crash if the stream is destroyed
Fixes: nodejs#24470
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
const http2 = require('http2'); | ||
|
||
// Check that writeHead, write and end do not crash in compatibikity mode | ||
|
||
const server = http2.createServer(common.mustCall((req, res) => { | ||
// destroy the stream first | ||
req.stream.destroy(); | ||
|
||
res.writeHead(200); | ||
res.write('hello '); | ||
res.end('world'); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const client = http2.connect(`http://localhost:${server.address().port}`); | ||
|
||
const req = client.request(); | ||
req.on('response', common.mustNotCall()); | ||
req.on('close', common.mustCall((arg) => { | ||
client.close(); | ||
server.close(); | ||
})); | ||
req.resume(); | ||
})); |