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.mustNotCall()); 12server.on('session', common.mustCall((session) => { 13 // This will force the connection to close because once extended connect 14 // is on, it cannot be turned off. The server is behaving badly. 15 session.settings({ enableConnectProtocol: false }); 16})); 17 18server.listen(0, common.mustCall(() => { 19 const client = http2.connect(`http://localhost:${server.address().port}`); 20 client.on('remoteSettings', common.mustCall((settings) => { 21 assert(settings.enableConnectProtocol); 22 const req = client.request({ 23 ':method': 'CONNECT', 24 ':protocol': 'foo' 25 }); 26 req.on('error', common.mustCall(() => { 27 server.close(); 28 })); 29 })); 30})); 31