- Version: v10.15.3
- Platform: Darwin
- Subsystem: http2
There are some inconsistencies with what the documentation states and what the http2 actually does regarding the http2.connect(authority, options, ...) method.
The documentation states that the method accepts both net.connect(...) and tls.connect(...) options, but if you pass in an authority object with the connection details and an options object with extra details, the method is inconsistent when deciding if authority should take precedence over options depending on if it uses net.connect(...) and tls.connect(...).
Assume that a server is running on localhost:1050, then consider:
const client = http2.connect('http://localhost:1050', { host: 'broken', port: 1337 })
and
const client = http2.connect('https://localhost:1050', { host: 'broken', port: 1337 })
In the first scenario, the connection will be successful since net.connect(...) uses the host and port in the authority arg, and ignores the options arg (if they're already defined in authority).
In the second scenario, since the connection is using tls.connect(...) instead of net.connect(...), the options object will take precedence over authority.
There are some inconsistencies with what the documentation states and what the http2 actually does regarding the
http2.connect(authority, options, ...)method.The documentation states that the method accepts both
net.connect(...)andtls.connect(...)options, but if you pass in anauthorityobject with the connection details and anoptionsobject with extra details, the method is inconsistent when deciding ifauthorityshould take precedence overoptionsdepending on if it usesnet.connect(...)andtls.connect(...).Assume that a server is running on
localhost:1050, then consider:and
In the first scenario, the connection will be successful since
net.connect(...)uses the host and port in the authority arg, and ignores the options arg (if they're already defined in authority).In the second scenario, since the connection is using
tls.connect(...)instead ofnet.connect(...), theoptionsobject will take precedence overauthority.