-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http: reset stream to unconsumed in unconsume()
#14410
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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.request({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (feel free to ignore): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lpinca done |
||
port: server.address().port, | ||
headers: { | ||
'Connection': 'Upgrade', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Even though we agreed not to lint quote-props in #14059, most people seem to prefer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the quotes for map-like objects :) |
||
'Upgrade': 'websocket' | ||
} | ||
}).on('error', () => {}).end(); | ||
})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the
hasCrypto
skip check.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cjihrig Thanks for pointing that out, done