summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-11 18:37:18 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-11 18:37:18 +0000
commit468985371143fc0f1f86c60897fa64c22321c8fc (patch)
tree0442c3fd2e17fa510ad6ea948221224dbf1069fe /lib
parentdea582458af3ac34fcaad7fd8de46560c012fb3b (diff)
* lib/net/http.rb (Net::HTTP#connect): use local_host and local_port
if specified. patched by Ricardo Amorim [Feature #6617] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/net/http.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 9521f6c20a..7efea79cdd 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -587,6 +587,8 @@ module Net #:nodoc:
def initialize(address, port = nil)
@address = address
@port = (port || HTTP.default_port)
+ @local_host = nil
+ @local_port = nil
@curr_http_version = HTTPVersion
@keep_alive_timeout = 2
@last_communicated = nil
@@ -631,6 +633,12 @@ module Net #:nodoc:
# The port number to connect to.
attr_reader :port
+ # The local host used to estabilish the connection.
+ attr_accessor :local_host
+
+ # The local port used to estabilish the connection.
+ attr_accessor :local_port
+
# Number of seconds to wait for the connection to open. Any number
# may be used, including Floats for fractional seconds. If the HTTP
# object cannot open a connection in this many seconds, it raises a
@@ -799,7 +807,7 @@ module Net #:nodoc:
def connect
D "opening connection to #{conn_address()}..."
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) {
- TCPSocket.open(conn_address(), conn_port())
+ TCPSocket.open(conn_address(), conn_port(), @local_host, @local_port)
}
D "opened"
if use_ssl?