From f17b3008197b81b8afaefb7de2ed43187620a1dc Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Mon, 17 Nov 2014 23:45:39 -0200 Subject: [PATCH] Retrive proxy user and password from http_proxy Get user and pass from http_proxy variable when specified, so that NET::HTTP can handle connections behind authenticated proxies automatically. --- lib/net/http.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index aceb530..19d6ea9 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1051,12 +1051,20 @@ def proxy_port # The proxy username, if one is configured def proxy_user - @proxy_user + if @proxy_from_env then + proxy_uri && proxy_uri.user + else + @proxy_user + end end # The proxy password, if one is configured def proxy_pass - @proxy_pass + if @proxy_from_env then + proxy_uri && proxy_uri.password + else + @proxy_pass + end end alias proxyaddr proxy_address #:nodoc: obsolete