Closed bisubus closed 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.
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.
A few problems persist with extending existing ProxyAgent
opts
object isn't reusable after construction, there's no way to tell fromthis.proxy
if the option is there on purpose (likeopts.secureEndpoint
) or it was parsed from URIproxyFn
) after instantiation is to recreate the whole constructor logicThis could be fixed by exposing
this.opts
andthis.proxies
and moving almost all constructor code to something likethis.setProxyUri
(proxyUri
accessors would be ok, too). BTW, this may improve unit-testability.