-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http2: fix error stream write followed by destroy
PR-URL: #35951 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Ricky Zhou <[email protected]> Reviewed-By: Rich Trott <[email protected]>
- Loading branch information
1 parent
1453de1
commit 92bd7b5
Showing
2 changed files
with
40 additions
and
1 deletion.
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,37 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
if (!common.hasCrypto) { | ||
common.skip('missing crypto'); | ||
} | ||
|
||
const http2 = require('http2'); | ||
const assert = require('assert'); | ||
|
||
const server = http2.createServer(); | ||
|
||
server.on('session', common.mustCall(function(session) { | ||
session.on('stream', common.mustCall(function(stream) { | ||
stream.on('end', common.mustCall(function() { | ||
this.respond({ | ||
':status': 200 | ||
}); | ||
this.write('foo'); | ||
this.destroy(); | ||
})); | ||
stream.resume(); | ||
})); | ||
})); | ||
|
||
server.listen(0, function() { | ||
const client = http2.connect(`http://localhost:${server.address().port}`); | ||
const stream = client.request({ ':method': 'POST' }); | ||
stream.on('response', common.mustCall(function(headers) { | ||
assert.strictEqual(headers[':status'], 200); | ||
})); | ||
stream.on('close', common.mustCall(() => { | ||
client.close(); | ||
server.close(); | ||
})); | ||
stream.resume(); | ||
stream.end(); | ||
}); |