Project

General

Profile

Feature #10652 ยป f17b3008197b81b8afaefb7de2ed43187620a1dc.patch.txt

lib/net/http.rb - xfalcox (Rafael Silva), 12/25/2014 09:50 PM

 
1
From f17b3008197b81b8afaefb7de2ed43187620a1dc Mon Sep 17 00:00:00 2001
2
From: Rafael dos Santos Silva <xfalcox@gmail.com>
3
Date: Mon, 17 Nov 2014 23:45:39 -0200
4
Subject: [PATCH] Retrive proxy user and password from http_proxy
5

    
6
Get user and pass from http_proxy variable when specified, so that NET::HTTP can handle connections behind authenticated proxies automatically.
7
---
8
 lib/net/http.rb | 12 ++++++++++--
9
 1 file changed, 10 insertions(+), 2 deletions(-)
10

    
11
diff --git a/lib/net/http.rb b/lib/net/http.rb
12
index aceb530..19d6ea9 100644
13
--- a/lib/net/http.rb
14
+++ b/lib/net/http.rb
15
@@ -1051,12 +1051,20 @@ def proxy_port
16
 
17
     # The proxy username, if one is configured
18
     def proxy_user
19
-      @proxy_user
20
+      if @proxy_from_env then
21
+        proxy_uri && proxy_uri.user
22
+      else
23
+        @proxy_user
24
+      end
25
     end
26
 
27
     # The proxy password, if one is configured
28
     def proxy_pass
29
-      @proxy_pass
30
+      if @proxy_from_env then
31
+        proxy_uri && proxy_uri.password
32
+      else
33
+        @proxy_pass
34
+      end
35
     end
36
 
37
     alias proxyaddr proxy_address   #:nodoc: obsolete