diff options
author | James M Snell <jasnell@gmail.com> | 2018-10-05 15:09:07 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2018-10-08 08:41:35 -0700 |
commit | 0ad8c7319d6034fff0175bdf61ba8970db06a8ba (patch) | |
tree | 3e42a84182f295ed552870f184fbbf64f4018912 /test | |
parent | 8290015d0a2f1a5d5947c31d6187b865fbe2ac9f (diff) | |
download | android-node-v8-0ad8c7319d6034fff0175bdf61ba8970db06a8ba.tar.gz android-node-v8-0ad8c7319d6034fff0175bdf61ba8970db06a8ba.tar.bz2 android-node-v8-0ad8c7319d6034fff0175bdf61ba8970db06a8ba.zip |
http2: add RFC 8441 extended connect protocol support
PR-URL: https://github.com/nodejs/node/pull/23284
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-http2-binding.js | 4 | ||||
-rw-r--r-- | test/parallel/test-http2-connect-method-extended-cant-turn-off.js | 30 | ||||
-rw-r--r-- | test/parallel/test-http2-connect-method-extended.js | 39 |
3 files changed, 72 insertions, 1 deletions
diff --git a/test/parallel/test-http2-binding.js b/test/parallel/test-http2-binding.js index ae19149d1b..6991f98afd 100644 --- a/test/parallel/test-http2-binding.js +++ b/test/parallel/test-http2-binding.js @@ -99,6 +99,7 @@ const expectedHeaderNames = { HTTP2_HEADER_AUTHORITY: ':authority', HTTP2_HEADER_SCHEME: ':scheme', HTTP2_HEADER_PATH: ':path', + HTTP2_HEADER_PROTOCOL: ':protocol', HTTP2_HEADER_DATE: 'date', HTTP2_HEADER_ACCEPT_CHARSET: 'accept-charset', HTTP2_HEADER_ACCEPT_ENCODING: 'accept-encoding', @@ -219,7 +220,8 @@ const expectedNGConstants = { NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS: 3, NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE: 4, NGHTTP2_SETTINGS_MAX_FRAME_SIZE: 5, - NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: 6 + NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: 6, + NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL: 8 }; const defaultSettings = { diff --git a/test/parallel/test-http2-connect-method-extended-cant-turn-off.js b/test/parallel/test-http2-connect-method-extended-cant-turn-off.js new file mode 100644 index 0000000000..f4d033efe6 --- /dev/null +++ b/test/parallel/test-http2-connect-method-extended-cant-turn-off.js @@ -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(); + })); + })); +})); diff --git a/test/parallel/test-http2-connect-method-extended.js b/test/parallel/test-http2-connect-method-extended.js new file mode 100644 index 0000000000..bb424c73f0 --- /dev/null +++ b/test/parallel/test-http2-connect-method-extended.js @@ -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(); + })); +})); |