Issue #6546 has been updated by drbrain (Eric Hodel).

File net.http.proxy_from_env.3.patch added

=begin
Here is an updated patch that uses the battle-tested code from open-uri.  This patch reads the proxy from ((|ENV|)) by default like open-uri.  It is safe in a CGI environment just like open-uri.

Details:

URI::Generic#find_proxy was moved from lib/open-uri.rb to lib/uri/generic.rb.

Proxy configuration is now stored in the Net::HTTP instance, not the class.  This allows ((|no_proxy|)) to work at connect time.

For compatibility, Net::HTTP.Proxy still returns an anonymous subclass of Net::HTTP, but this subclass only stores proxy configuration information.  When new is called the proxy configuration is copied from the class to the instance. 

Removed use of Net::HTTP::ProxyDelta.  The module still exists for use with lib/net/http/backward.rb.

Net::HTTP.new no longer calls Net::HTTP.Proxy.

Net::HTTP.newobj has been removed.

Net::HTTP#connect no longer calls #conn_address or #conn_port.  Instead it calls the new method #proxy?.  If the proxy information is being determined from ((|ENV|)) and the current connection is listed in ((|no_proxy|)) a direct connection is made, if it is not listed a proxy connection is made.  If a manual proxy has been configured a proxy connection is made.  If no proxy is configured a direct connection is made.

#proxy_address and #proxy_port may return nil if called when #proxy? returns false.  Since these methods were previously called only via ProxyDelta and conn_address and conn_port I don't think this should be a problem.

#conn_address and #conn_port always return #address and #port now.  Since these methods are private I don't think this should be a problem.

#edit_path has been updated to behave properly based on #proxy? and #use_ssl?

I have not altered open-uri to remove it's built-in proxy handling.

I ran the tests with ((|http_proxy|)) pointing to a valid and invalid proxy with no problem. 
=end

----------------------------------------
Feature #6546: Net::HTTP to check for HTTP_PROXY environment setting.
https://bugs.ruby-lang.org/issues/6546#change-27532

Author: dekz (Jacob Evans)
Status: Assigned
Priority: Normal
Assignee: drbrain (Eric Hodel)
Category: lib
Target version: 2.0.0


@nahi suggested I request the OS environment HTTP_PROXY be honoured.

Open-uri checks for this environment setting and acts according whereas Net::HTTP does not. Not having Net::HTTP check for this condition sets precedence and stops the implementation of other environment settings (such as JRuby and JVM -Dhttp.proxyHost). 

Having this functionality will greatly enable testing with proxies rather then monkey patching or rewriting to always use HTTP.Proxy.


-- 
http://bugs.ruby-lang.org/