-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http2: add RFC 8441 extended connect protocol support
PR-URL: #23284 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
- Loading branch information
Showing
9 changed files
with
135 additions
and
6 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
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
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
30 changes: 30 additions & 0 deletions
30
test/parallel/test-http2-connect-method-extended-cant-turn-off.js
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,30 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
const assert = require('assert'); | ||
const http2 = require('http2'); | ||
|
||
const settings = { enableConnectProtocol: true }; | ||
const server = http2.createServer({ settings }); | ||
server.on('stream', common.mustNotCall()); | ||
server.on('session', common.mustCall((session) => { | ||
// This will force the connection to close because once extended connect | ||
// is on, it cannot be turned off. The server is behaving badly. | ||
session.settings({ enableConnectProtocol: false }); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const client = http2.connect(`http://localhost:${server.address().port}`); | ||
client.on('remoteSettings', common.mustCall((settings) => { | ||
assert(settings.enableConnectProtocol); | ||
const req = client.request({ | ||
':method': 'CONNECT', | ||
':protocol': 'foo' | ||
}); | ||
req.on('error', common.mustCall(() => { | ||
server.close(); | ||
})); | ||
})); | ||
})); |
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,39 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
const assert = require('assert'); | ||
const http2 = require('http2'); | ||
|
||
const settings = { enableConnectProtocol: true }; | ||
const server = http2.createServer({ settings }); | ||
server.on('stream', common.mustCall((stream, headers) => { | ||
assert.strictEqual(headers[':method'], 'CONNECT'); | ||
assert.strictEqual(headers[':scheme'], 'http'); | ||
assert.strictEqual(headers[':protocol'], 'foo'); | ||
assert.strictEqual(headers[':authority'], | ||
`localhost:${server.address().port}`); | ||
assert.strictEqual(headers[':path'], '/'); | ||
stream.respond(); | ||
stream.end('ok'); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const client = http2.connect(`http://localhost:${server.address().port}`); | ||
client.on('remoteSettings', common.mustCall((settings) => { | ||
assert(settings.enableConnectProtocol); | ||
const req = client.request({ | ||
':method': 'CONNECT', | ||
':protocol': 'foo' | ||
}); | ||
req.resume(); | ||
req.on('end', common.mustCall()); | ||
req.on('close', common.mustCall(() => { | ||
assert.strictEqual(req.rstCode, 0); | ||
server.close(); | ||
client.close(); | ||
})); | ||
req.end(); | ||
})); | ||
})); |