aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
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?