|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +// Ref: https://github.com/nodejs/node/issues/39919 |
| 4 | + |
| 5 | +const common = require('../common'); |
| 6 | +if (!common.hasCrypto) |
| 7 | + common.skip('missing crypto'); |
| 8 | + |
| 9 | +const assert = require('assert'); |
| 10 | +const http2 = require('http2'); |
| 11 | + |
| 12 | +function _verifyOriginSet(session, originString) { |
| 13 | + session.once('remoteSettings', () => { |
| 14 | + assert.strictEqual(typeof session.originSet, 'object'); |
| 15 | + assert.strictEqual(session.originSet.length, 1); |
| 16 | + assert.strictEqual(session.originSet[0], originString); |
| 17 | + session.close(); |
| 18 | + }); |
| 19 | + session.once('error', (error) => { |
| 20 | + assert.strictEqual(error.code, 'ECONNREFUSED'); |
| 21 | + session.close(); |
| 22 | + }); |
| 23 | +} |
| 24 | + |
| 25 | +function withServerName() { |
| 26 | + const session = http2.connect('https://1.1.1.1', { servername: 'cloudflare-dns.com' }); |
| 27 | + _verifyOriginSet(session, 'https://cloudflare-dns.com'); |
| 28 | +} |
| 29 | + |
| 30 | +function withEmptyServerName() { |
| 31 | + const session = http2.connect('https://1.1.1.1', { servername: '' }); |
| 32 | + _verifyOriginSet(session, 'https://1.1.1.1'); |
| 33 | +} |
| 34 | + |
| 35 | +function withoutServerName() { |
| 36 | + const session = http2.connect('https://1.1.1.1'); |
| 37 | + _verifyOriginSet(session, 'https://1.1.1.1'); |
| 38 | +} |
| 39 | + |
| 40 | +withServerName(); |
| 41 | +withEmptyServerName(); |
| 42 | +withoutServerName(); |
0 commit comments