Closed jportner closed 1 year ago
Latest commit: a841e14c665794cf489069803dcb6ab755aa8f1b
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Updated (UTC) |
---|---|---|---|
proxy-agents | ✅ Ready (Inspect) | Visit Preview | May 16, 2023 4:20am |
Thank you for identifying the primary bug in http-proxy-agent
, and for this PR, and for all the descriptive comments! I do have an ask though, since this seems to be addressing a few different issues in multiple modules: can we break this up into a few smaller more focused PRs?
http-proxy-agent
fix (I actually think the setRequestPropsOnConnect
thing won't be necessary, see next point).pac-proxy-agent
seems to only address the http-proxy-agent
module case. In actuality, keepAlive
is pretty broken in general for that module right now. It needs an agent caching mechanism like proxy-agent
has.satisfies
could be its own PR.agent-base
changes seem like they might be affected by https://github.com/TooTallNate/proxy-agents/pull/170.Thank you for identifying the primary bug in
http-proxy-agent
, and for this PR, and for all the descriptive comments!
Sure thing, I'm glad I can contribute!
I do have an ask though, since this seems to be addressing a few different issues in multiple modules: can we break this up into a few smaller more focused PRs?
Yeah... I set out to do one thing and it ballooned a bit. I'm happy to split this up, I'll take a crack at it tomorrow morning.
I do have an ask though, since this seems to be addressing a few different issues in multiple modules: can we break this up into a few smaller more focused PRs?
Yeah... I set out to do one thing and it ballooned a bit. I'm happy to split this up, I'll take a crack at it tomorrow morning.
OK, I descoped this PR to focus on fixing HttpProxyAgent as requested, this is ready for review whenever you have time.
Hey @jportner! Sorry for the delayed review. I dove into your branch to get a better understanding. I'm proposing this slight altercation instead: https://github.com/TooTallNate/proxy-agents/pull/190 (still giving you credit as the commit author). Let me know what you think!
Hey @jportner! Sorry for the delayed review. I dove into your branch to get a better understanding. I'm proposing this slight altercation instead: #190 (still giving you credit as the commit author). Let me know what you think!
Thanks, looks good to me! I like your approach of checking the path instead of setting a flag on the request object.
Looking forward to any more follow-up PRs from you as well 😃
I was testing the new
keepAlive
option, and it turns out that while it works for https-proxy-agent, it doesn't work with http-proxy-agent.I use Smokescreen, and when testing keepAlive with http-proxy-agent, the first request succeeded, but all subsequent requests failed with an error: "This is a proxy server. Does not respond to non-proxy requests"
Turns out, the first request used an absolute URL (
http://localhost:3000/foo
) while all subsequent requests used relative URLs (/foo
). HTTP proxy servers require that HTTP requests use absolute URLs, which is why this happens. (HTTPS requests are not impacted because they are encrypted, and regular non-MITM proxies cannot read the URL).The http-proxy-agent package already had logic to rewrite the relative URL to an absolute URL:
https://github.com/TooTallNate/proxy-agents/blob/2f835a41f265280192b82556db80ccbe67140753/packages/http-proxy-agent/src/index.ts#L88-L90
However, that only happens on
connect()
, so it only worked on the first request. This PR makes the following changes: