Skip to content

HTTP and HTTPS agent #588

@normanrz

Description

@normanrz

I am trying to use keep-alive agent with node-fetch as described in #423, but I have a problem with HTTPS redirects. Initially, I call a HTTP resource which returns a redirect to a HTTPS resource. In the default node-fetch this is not a problem, because the agent is set based on the current request. When overriding the agent there is no way of having per-request agents.

I would propose an API that allows a function instead of a fixed agent:

fetch(url, { agent: (protocol) => protocol === 'https' ? httpsAgent : httpAgent })

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions