Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/dispatcher/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class Client extends DispatcherBase {
throw new InvalidArgumentError('h2Options.settings.initialWindowSize must be a positive integer, greater than 0')
}

if (h2Options.maxConcurrentStreams != null && (!Number.isInteger(h2Options.connectionWindowSize) || h2Options.maxConcurrentStreams < 1)) {
if (h2Options.maxConcurrentStreams != null && (!Number.isInteger(h2Options.maxConcurrentStreams) || h2Options.maxConcurrentStreams < 1)) {
throw new InvalidArgumentError('h2Options.maxConcurrentStreams must be a positive integer, greater than 0')
}

Expand Down
19 changes: 19 additions & 0 deletions test/http2-instantiation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { once } = require('node:events')
const pem = require('@metcoder95/https-pem')

const { Client } = require('..')
const { kHTTP2Options } = require('../lib/core/symbols')

test('Should throw if bad allowH2 has been passed', async t => {
t = tspl(t, { plan: 1 })
Expand Down Expand Up @@ -50,6 +51,24 @@ test('Should throw if bad maxConcurrentStreams has been passed', async t => {
await t.completed
})

test('Should accept each h2Options field on its own', async t => {
const p = tspl(t, { plan: 3 })

const maxConcurrentStreams = new Client('https://localhost:1000', { allowH2: true, h2Options: { maxConcurrentStreams: 10 } })
t.after(() => maxConcurrentStreams.close())
p.strictEqual(maxConcurrentStreams[kHTTP2Options].maxConcurrentStreams, 10)

const connectionWindowSize = new Client('https://localhost:1000', { allowH2: true, h2Options: { connectionWindowSize: 65535 } })
t.after(() => connectionWindowSize.close())
p.strictEqual(connectionWindowSize[kHTTP2Options].connectionWindowSize, 65535)

const pingInterval = new Client('https://localhost:1000', { allowH2: true, h2Options: { pingInterval: 1000 } })
t.after(() => pingInterval.close())
p.strictEqual(pingInterval[kHTTP2Options].pingInterval, 1000)

await p.completed
})

test(
'Request should fail if allowH2 is false and server advertises h1 only',
async t => {
Expand Down
Loading