Skip to content

Add explicit nil proxy arguments - Corrects no_proxy support #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 25, 2019

Conversation

jakauppila
Copy link
Contributor

Currently, when a hostname matches a value contained within the no_proxy environment variable, no proxy value is added to the net_http_args which ultimately get passed to Net::HTTP.new().

When this occurs and explicit nil values are not passed, Net::HTTP will fall back to the http_proxy and https_proxy environment variables thus ignoring no_proxy so the request will traverse the proxy erroneously.

https://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/Net/HTTP.html#method-c-new

bundlerbot added a commit to rubygems/bundler that referenced this pull request Jun 23, 2017
Add explicit nil proxy arguments - Fixes no_proxy support

### What was the end-user problem that led to this PR?

When the `no_proxy` environment variable is configured it is not being honored and requests for hosts that are present in the list will be sent through the proxy defined via `http_proxy` and `https_proxy`.

Ultimately this means that a user utilizing the `http_proxy`, `https_proxy`, and `no_proxy` environment variables will unable to access an internal RubyGems source.

### Was was your diagnosis of the problem?

The underlying `net-http-persistent` gem currently does not explicitly pass in nil arguments when a host matches a value within `no_proxy`, so when `Net::HTTP.new()` is called, it will fall back an utilize the values defined in `http_proxy` and `https_proxy`.

drbrain/net-http-persistent#88 has been submitted to add the explicit nil argument to be defined.

### What is your fix for the problem, implemented in this PR?

Adding explicit nil arguments for the proxy definition for `Net::HTTP.new()` as defined by the documentation.

https://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/Net/HTTP.html#method-c-new

### Why did you choose this fix out of the possible options?

Per the discussion in #5781, as Bundler is currently stuck to v2.9.4 of `net-http-persistent` for now, it would be best addressed by a change to the vendored code.

A PR has been submitted to `net-http-persistent` which can be pulled into Bundler when v3.x will be integrated.
segiddins pushed a commit to rubygems/bundler that referenced this pull request Jul 17, 2017
Add explicit nil proxy arguments - Fixes no_proxy support

### What was the end-user problem that led to this PR?

When the `no_proxy` environment variable is configured it is not being honored and requests for hosts that are present in the list will be sent through the proxy defined via `http_proxy` and `https_proxy`.

Ultimately this means that a user utilizing the `http_proxy`, `https_proxy`, and `no_proxy` environment variables will unable to access an internal RubyGems source.

### Was was your diagnosis of the problem?

The underlying `net-http-persistent` gem currently does not explicitly pass in nil arguments when a host matches a value within `no_proxy`, so when `Net::HTTP.new()` is called, it will fall back an utilize the values defined in `http_proxy` and `https_proxy`.

drbrain/net-http-persistent#88 has been submitted to add the explicit nil argument to be defined.

### What is your fix for the problem, implemented in this PR?

Adding explicit nil arguments for the proxy definition for `Net::HTTP.new()` as defined by the documentation.

https://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/Net/HTTP.html#method-c-new

### Why did you choose this fix out of the possible options?

Per the discussion in #5781, as Bundler is currently stuck to v2.9.4 of `net-http-persistent` for now, it would be best addressed by a change to the vendored code.

A PR has been submitted to `net-http-persistent` which can be pulled into Bundler when v3.x will be integrated.

(cherry picked from commit 4dfff8b)
@drbrain drbrain merged commit 4cb8246 into drbrain:master Jul 25, 2019
hsbt pushed a commit to rubygems/bundler-graph that referenced this pull request Oct 19, 2021
Add explicit nil proxy arguments - Fixes no_proxy support

### What was the end-user problem that led to this PR?

When the `no_proxy` environment variable is configured it is not being honored and requests for hosts that are present in the list will be sent through the proxy defined via `http_proxy` and `https_proxy`.

Ultimately this means that a user utilizing the `http_proxy`, `https_proxy`, and `no_proxy` environment variables will unable to access an internal RubyGems source.

### Was was your diagnosis of the problem?

The underlying `net-http-persistent` gem currently does not explicitly pass in nil arguments when a host matches a value within `no_proxy`, so when `Net::HTTP.new()` is called, it will fall back an utilize the values defined in `http_proxy` and `https_proxy`.

drbrain/net-http-persistent#88 has been submitted to add the explicit nil argument to be defined.

### What is your fix for the problem, implemented in this PR?

Adding explicit nil arguments for the proxy definition for `Net::HTTP.new()` as defined by the documentation.

https://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/Net/HTTP.html#method-c-new

### Why did you choose this fix out of the possible options?

Per the discussion in rubygems/bundler#5781, as Bundler is currently stuck to v2.9.4 of `net-http-persistent` for now, it would be best addressed by a change to the vendored code.

A PR has been submitted to `net-http-persistent` which can be pulled into Bundler when v3.x will be integrated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants