Skip to content

doc: Options passed needlessly to https request object and agent prop #35360

Open
@netanel-haber

Description

@netanel-haber

📗 API Reference Docs Problem

  • Version: v14.12.0

Location

Affected URL(s):

Description

In the following example provided for the https.request method, the request config object is passed both to the top level https request object, and to the agent property of said object.
This seems to either be a typo, or unclear. I would expect to see the following:

  • "key" and "cert" should be provided to the agent object only, and should not appear at the top level of the options object.
  • The properties that comprise the URL object ("hostname", "port", "path" and "method") should not be provided to the agent object.

I think this would avoid confusion.

const options = {
  hostname: 'encrypted.google.com',
  port: 443,
  path: '/',
  method: 'GET',
  key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
  cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
};
options.agent = new https.Agent(options);

const req = https.request(options, (res) => {
  // ...
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.httpsIssues or PRs related to the https subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions