Skip to content

Handling for HTTP(S)_PROXY and NO_PROXY #2446

@unterwegi

Description

@unterwegi

Currently, the documentation mentions that applications should handle proxy server related environment variables on their own.

We are currently doing that in our app and we were wondering, if we should contribute the handling we've built back to the library.
Our implementation doesn't just read the HTTP_PROXY/HTTPS_PROXY variables, it also handles NO_PROXY lists, which have some nasty pitfalls to consider when you want to handle those correctly.
https://about.gitlab.com/blog/we-need-to-talk-no-proxy/ has a good explanation and some hints, which our implementation follows (prefer lowercase variable names, domain suffix and CIDR matching in NO_PROXY, no DNS lookups, ...).

This extra proxy environment handling should be an optional feature of course and not affect current setups.

First, we would need a way to provide the NO_PROXY list to the client, could be a new function related to the current set_proxy functions:

client.set_no_proxy({"foo.org", "bar.org"});

Of course, the parts that reference the configured proxy need to check if the target host matches a no_proxy list entry and simply don't use the proxy if it does.

Also, maybe a helper could then make sense for parsing the environment variables and calling the respective proxy setup functions.

client.set_proxy_from_env();

I could start a PR if this feature sounds like something you want.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions