Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ProxyAgent take another Agent as an option #1962

Closed
mcollina opened this issue Feb 22, 2023 · 2 comments
Closed

Make ProxyAgent take another Agent as an option #1962

mcollina opened this issue Feb 22, 2023 · 2 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@mcollina
Copy link
Member

In

this[kAgent] = new Agent(opts)
, we create a new Agent for every ProxyAgent. I think we should make ProxyAgent take an instance of Agent as an option, making something like the following possible:

import { ProxyAgent, request, setGlobalDispatcher } from "undici"
import { CookieAgent } from "http-cookie-agent/undici"
import { CookieJar } from "tough-cookie"


async function test() {
  const proxyAgent = new ProxyAgent("http://127.0.0.1:10810")
  setGlobalDispatcher(proxyAgent)
  const jar = new CookieJar()
  const agent = new CookieAgent({ cookies: { jar } })
  await request("https://test.com", {
    dispatcher: agent,
  })
}

Help would be greatly appreciated! 🙏

Originally posted by @tgioer in #1957

@mcollina mcollina added the good first issue Good for newcomers label Feb 22, 2023
@RishabhKodes
Copy link
Contributor

Hey @mcollina, I'm taking up this issue.

@jabali2004
Copy link

Hey @mcollina 👋🏼
Can we close that one? Since #2003 has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants