1'use strict'; 2 3const common = require('../common'); 4if (!common.hasCrypto) 5 common.skip('missing crypto'); 6const assert = require('assert'); 7const http2 = require('http2'); 8 9const settings = { enableConnectProtocol: true }; 10const server = http2.createServer({ settings }); 11server.on('stream', common.mustCall((stream, headers) => { 12 assert.strictEqual(headers[':method'], 'CONNECT'); 13 assert.strictEqual(headers[':scheme'], 'http'); 14 assert.strictEqual(headers[':protocol'], 'foo'); 15 assert.strictEqual(headers[':authority'], 16 `localhost:${server.address().port}`); 17 assert.strictEqual(headers[':path'], '/'); 18 stream.respond(); 19 stream.end('ok'); 20})); 21 22server.listen(0, common.mustCall(() => { 23 const client = http2.connect(`http://localhost:${server.address().port}`); 24 client.on('remoteSettings', common.mustCall((settings) => { 25 assert(settings.enableConnectProtocol); 26 const req = client.request({ 27 ':method': 'CONNECT', 28 ':protocol': 'foo' 29 }); 30 req.resume(); 31 req.on('end', common.mustCall()); 32 req.on('close', common.mustCall(() => { 33 assert.strictEqual(req.rstCode, 0); 34 server.close(); 35 client.close(); 36 })); 37 req.end(); 38 })); 39})); 40