Skip to content

http2.connect(...) - overriding authority with options #28182

@rishabh

Description

@rishabh
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    http2Issues or PRs related to the http2 subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions