-
-
Notifications
You must be signed in to change notification settings - Fork 935
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
Basic proxy support #159
Basic proxy support #159
Conversation
Added really basic proxy support. It works for the simple use case of got("reddit.com") which will first make a http request and then be redirected to https. This also supports requests that are redirected and over to unsecure locations i.e. they start http and stay http. Currently requests that require https to begin with are not supported.
From that issue:
|
Sorry, I should have read the issue properly. I will move it. I guess you would rather have it replace http/https? Probably will make it easier from my PoV as well.
|
Closing as will create a new one referencing a new npm lib. |
Yes, or even better, a custom http agent. |
I have a branch with this working. No tests yet. I will push on Monday once
|
@tgandrews , I've seen your branch but what I miss is a way where got uses proxies in a transparent way, without passing a opts.proxy value. This follows the need for proxies when using tools like npm-name, generator-node, etc... I've did some work on #178 following the approach from request but @sindresorhus pointed out how wrong it could get 👎 |
@alexsantos I'll try and dig out the branch. I had a bit of down time in a new job (with big company network setup) but have not looked at this for a while. |
@tgandrews and @sindresorhus , I have another branch which I think is the minimalist solution for this. It depends on proxy-from-env and proxy-agent modules. Can you have a look here? https://github.com/alexsantos/got/tree/proxy-from-env/index.js if (!opts.agent) {
const proxy = getProxyForUrl(url);
if (proxy) {
opts.agent = new ProxyAgent(proxy);
}
} I could have done a PR but didn't want to bug Sindre again :-) |
@alexsantos Yes, something like that is what I was thinking. Unfortunately the |
// @floatdrop |
May be same trick as in http2 issue can be applied here as well? |
@floatdrop Unfortunately not to achieve what most people requesting this want, as they want modules or modules of modules using got somewhere in the chain to support proxies transparently. Should be possible to find/create a smaller dependency though. |
@floatdrop , just to back @sindresorhus message, I came here because I want to use yeoman generators at work and I can't because of the lack of proxy support on got. |
@sindresorhus @alexsantos My branch was using proxy-agent as well. I guess we need to support just HTTP and HTTPS proxies? If we are doing the whole whack then I doubt we are going to do better than node-proxy-agent |
This feature is probably one of the things that makes |
@tgandrews The size of node-proxy-agent is derived from the fact that it supports PAC and that module specfically needs degenerator/esprima which is a huge dependency. If we abandon PAC then it gets pretty small. I've been doing some work on that module so I'll might drop PAC and fork it to a smaller one. |
OK, I guess there are two options:
And @alexsantos is looking(?) into number 1, so I'll have a look at number 2 then if I get some free time. |
@tgandrews , I already have a stripped version of node-pac-resolver (now with Promises) that gets rid of regenerator. https://github.com/alexsantos/node-pac-resolver/tree/nodev4-compat |
@alexsantos Let me know if there is anything I can do to help. |
Why fork node-proxy-agent when you could create a PR to bring it up to date? Or was that the intent? |
@stevenvachon , node-proxy-agent has pac-proxy support, which is a huge dependency for got. |
Do we not need to support pac and socks proxies? |
Does it support socks5 proxy? |
This PR is intended to start a discussion, possibly get some extra help and feedback on the direction It aims to resolve the issue #79
N.B. I am working on removing the spacing and line ending changes to make the PR more readable.
Added really basic proxy support. It works for the simple use case of
got("reddit.com") which will first make a http request and then be
redirected to https. This also supports requests that are redirected and
over to unsecure locations i.e. they start http and stay http.
Currently requests that require https to begin with are not supported.