summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-21 15:45:10 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-21 15:45:10 +0000
commit07a6d0e9d112db7276492bcaf0856e04399232c1 (patch)
treecd5bda2fea60bcae2445788e7910a72a7adfed45 /lib
parent36c45154d609e97f45ea1fca2477d9675f414616 (diff)
* lib/net/http.rb (Net::HTTP.newobj): return back for compatibility.
* lib/net/http.rb (Net::HTTP.new): set default_port if proxy port is not given. * lib/net/http.rb (Net::HTTP#initialize): ditto. * lib/net/http.rb (Net::HTTP#proxy?): return true or false. * lib/net/http.rb (Net::HTTP#proxy_address): check proxy_uri is not nil. * lib/net/http.rb (Net::HTTP#proxy_port): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/net/http.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 96e95ec3ad..5a4d553388 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -577,6 +577,10 @@ module Net #:nodoc:
http.start(&block)
end
+ class << HTTP
+ alias newobj new # :nodoc:
+ end
+
# Creates a new Net::HTTP object without opening a TCP connection or
# HTTP session.
#
@@ -609,7 +613,7 @@ module Net #:nodoc:
http.proxy_from_env = true
else
http.proxy_address = p_addr
- http.proxy_port = p_port
+ http.proxy_port = p_port || default_port
http.proxy_user = p_user
http.proxy_pass = p_pass
end
@@ -964,7 +968,7 @@ module Net #:nodoc:
@proxy_port = nil
else
@proxy_address = p_addr
- @proxy_port = p_port
+ @proxy_port = p_port || default_port
end
@proxy_user = p_user
@@ -994,7 +998,7 @@ module Net #:nodoc:
# True if requests for this connection will be proxied
def proxy?
- if @proxy_from_env then
+ !!if @proxy_from_env then
proxy_uri
else
@proxy_address
@@ -1014,7 +1018,7 @@ module Net #:nodoc:
# The address of the proxy server, if one is configured.
def proxy_address
if @proxy_from_env then
- proxy_uri.hostname
+ proxy_uri && proxy_uri.hostname
else
@proxy_address
end
@@ -1023,7 +1027,7 @@ module Net #:nodoc:
# The port of the proxy server, if one is configured.
def proxy_port
if @proxy_from_env then
- proxy_uri.port
+ proxy_uri && proxy_uri.port
else
@proxy_port
end