vert-x3 / issues

Apache License 2.0
36 stars 7 forks source link

Get Proxy configuration from system (env. variables or JVM properties) #557

Open aesteve opened 3 years ago

aesteve commented 3 years ago

Describe the feature

Vert.x has  ProxyOptions but doesn't take into account the system configuration:

Use cases

For every application working behind a (changing) corporate proxy, the creation of ProxyOptions from such environment has to be written manually.

Contribution

Don't have time to implement it at the moment.

Something worth looking at: https://github.com/seanmonstar/reqwest/commit/cff2a4e0f943205214a33c57d79c3d0d69d0fe62#diff-0df5342f97493f9f55d6f43a14268f327ea9e791c7fdb8df6d88ec81f6baa721R137 (reqwest Rust http client) The maintainer has been asked to integrate "system proxies" and the implementation looks really nice. First: a Proxy type which would just be ProxyOptions in the case of Vert.x Then: a constructor of such type from environment variables.: Proxy::system() which could translate to ProxyOptions.fromSystem() in the case of Vert.x. (would parse both environment variable and system properties. (with precedence for properties over env. variables) Finally: in the PR I linked above, Proxy::system() has been made the default if no custom Proxy is specified.

I guess we could follow such path: having a constructor for ProxyOptions that parses environment variables / system propertes. ProxyOptions::fromSystem(). The in a future version it could become the default when creating an http client (if another ProxyOptions has not been set by the API user)

Important notes:

⚠️Be really careful with nonProxyHosts and no_proxy and how they should match wildcards!⚠️ I'm wondering if "higher-level" libraries relying on Vert.x HTTP have already implemented such options, worth asking them.

vietj commented 3 years ago

thanks @aesteve it is interesting. I think we could support static method for creating proxy options but we would not use them by default