forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http2: set origin name correctly when servername is empty
Fixes: nodejs#39919
- Loading branch information
1 parent
449147e
commit c43b614
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
test/internet/test-http2-https-origin-string-correctness.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
|
||
// Ref: https://github.com/nodejs/node/issues/39919 | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const assert = require('assert'); | ||
const http2 = require('http2'); | ||
|
||
function _verifyOriginSet(session, originString) { | ||
session.once('remoteSettings', () => { | ||
assert.strictEqual(typeof session.originSet, 'object'); | ||
assert.strictEqual(session.originSet.length, 1); | ||
assert.strictEqual(session.originSet[0], originString); | ||
session.close(); | ||
}); | ||
session.once('error', (error) => { | ||
assert.strictEqual(error.code, 'ECONNREFUSED'); | ||
session.close(); | ||
}); | ||
} | ||
|
||
function withServerName() { | ||
const session = http2.connect('https://1.1.1.1', { servername: 'cloudflare-dns.com' }); | ||
_verifyOriginSet(session, 'https://cloudflare-dns.com'); | ||
} | ||
|
||
function withEmptyServerName() { | ||
const session = http2.connect('https://1.1.1.1', { servername: '' }); | ||
_verifyOriginSet(session, 'https://1.1.1.1'); | ||
} | ||
|
||
function withoutServerName() { | ||
const session = http2.connect('https://1.1.1.1'); | ||
_verifyOriginSet(session, 'https://1.1.1.1'); | ||
} | ||
|
||
withServerName(); | ||
withEmptyServerName(); | ||
withoutServerName(); |