TooTallNate / node-proxy-agent

Maps proxy protocols to `http.Agent` implementations
285 stars 69 forks source link

Change proxy in ProxyAgent instance #8

Closed bisubus closed 1 year ago

bisubus commented 8 years ago

ProxyAgent already handles other agents' instances and is able to instantiate them after its own construction. Can we make a proxy switchable in ProxyAgent instance?

So an instance could created, passed as agent to request library of choice and still able to change proxy URI on the fly.

In its most simple form it may be like that.

class SwitchableProxyAgent extends ProxyAgent {
    get proxyUri() {
        return this._uri;
    }

    set proxyUri(uri) {
        this._uri = uri;
        this.proxy = url.parse(uri);
    }
}

A few problems persist with extending existing ProxyAgent

This could be fixed by exposing this.opts and this.proxies and moving almost all constructor code to something like this.setProxyUri (proxyUri accessors would be ok, too). BTW, this may improve unit-testability.

TooTallNate commented 1 year ago

This code in this repository has been moved to the proxy-agents monorepo, so I am closing this pull request. If you feel that this issue still exists as of the latest release, feel free to open a new issue over there.