blackducksoftware / hub-rest-api-python

HUB REST API Python bindings
Apache License 2.0
89 stars 104 forks source link

Remove manually set proxy settings #215

Closed securitykernel closed 2 years ago

securitykernel commented 2 years ago

Setting proxy settings for the requests session manually from the environment variables is not necessary, since requests handles it itself.

When the proxies configuration is not overridden per request as shown above, Requests relies on the proxy configuration defined by standard environment variables http_proxy, https_proxy, no_proxy, and all_proxy. Uppercase variants of these variables are also supported.

In fact the way it is currently implemented the contents of the no_proxy variable is ignored, preventing the following common use case:

export https_proxy="http://proxy.corporate-network.com:9980"
export no_proxy=".corporate-network.com"

bd = Client(
    token=os.environ.get('blackduck_token'),
    base_url="https://blackduck.corporate-network.com")

Results in a connection error depending on the proxy behavior. Some proxies redirect, some proxies just hang up. The latter is the case especially when the proxy is not located inside the corporate network.

This change just removes the redundant proxy setup code so that requests can handle all proxy setup itself.

OffBy0x01 commented 2 years ago

All valid points, makes sense to simplify like this.