-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: reset stream to unconsumed in
unconsume()
Reset the underlying socket of an HTTP stream to be marked as unconsume after the HTTP parser no longer owns it. Fixes: #14407 PR-URL: #14410 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
- Loading branch information
1 parent
ca61f3b
commit 6707411
Showing
3 changed files
with
35 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
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 tls = require('tls'); | ||
const http = require('http'); | ||
|
||
// Tests that, after the HTTP parser stopped owning a socket that emits an | ||
// 'upgrade' event, another C++ stream can start owning it (e.g. a TLSSocket). | ||
|
||
const server = http.createServer(common.mustNotCall()); | ||
|
||
server.on('upgrade', common.mustCall((request, socket, head) => { | ||
// This should not crash. | ||
new tls.TLSSocket(socket); | ||
server.close(); | ||
socket.destroy(); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
http.get({ | ||
port: server.address().port, | ||
headers: { | ||
'Connection': 'Upgrade', | ||
'Upgrade': 'websocket' | ||
} | ||
}).on('error', () => {}); | ||
})); |