1'use strict'; 2const common = require('../common'); 3if (!common.hasCrypto) 4 common.skip('missing crypto'); 5const assert = require('assert'); 6const http2 = require('http2'); 7const makeDuplexPair = require('../common/duplexpair'); 8 9{ 10 const testData = '<h1>Hello World</h1>'; 11 const server = http2.createServer(); 12 server.on('stream', common.mustCall((stream, headers) => { 13 stream.respond({ 14 'content-type': 'text/html', 15 ':status': 200, 16 'cookie': 'donotindex', 17 'not-sensitive': 'foo', 18 'sensitive': 'bar', 19 // sensitiveHeaders entries are case-insensitive 20 [http2.sensitiveHeaders]: ['Sensitive'] 21 }); 22 stream.end(testData); 23 })); 24 25 const { clientSide, serverSide } = makeDuplexPair(); 26 server.emit('connection', serverSide); 27 28 const client = http2.connect('http://localhost:80', { 29 createConnection: common.mustCall(() => clientSide) 30 }); 31 32 const req = client.request({ ':path': '/' }); 33 34 req.on('response', common.mustCall((headers) => { 35 assert.strictEqual(headers[':status'], 200); 36 assert.strictEqual(headers.cookie, 'donotindex'); 37 assert.deepStrictEqual(headers[http2.sensitiveHeaders], 38 ['cookie', 'sensitive']); 39 })); 40 41 req.on('end', common.mustCall(() => { 42 clientSide.destroy(); 43 clientSide.end(); 44 })); 45 req.resume(); 46 req.end(); 47} 48