Permalink
Browse files

Added bind_connect method and bind variables

  • Loading branch information...
1 parent 2c9ec74 commit fd22918794b24623d4fec3afa8d3b0c738d71c00 Daniel committed Sep 10, 2011
Showing with 5 additions and 2 deletions.
  1. +1 −1 lib/em-http/http_connection.rb
  2. +4 −1 lib/em-http/http_connection_options.rb
@@ -49,7 +49,7 @@ def conn=(c)
def activate_connection(client)
begin
- EventMachine.connect(@connopts.host, @connopts.port, HttpStubConnection) do |conn|
+ EventMachine.bind_connect(@connopts.bind, @connopts.bind_port, @connopts.host, @connopts.port, HttpStubConnection) do |conn|
post_init
@deferred = false
@@ -1,5 +1,5 @@
class HttpConnectionOptions
- attr_reader :host, :port, :tls, :proxy
+ attr_reader :host, :port, :tls, :proxy, :bind, :bind_port
attr_reader :connect_timeout, :inactivity_timeout
def initialize(uri, options)
@@ -9,6 +9,9 @@ def initialize(uri, options)
@tls = options[:tls] || options[:ssl] || {}
@proxy = options[:proxy]
+ @bind = options[:bind] || '0.0.0.0'
+ @bind_port = options[:bind_port] || 0
+
uri = uri.kind_of?(Addressable::URI) ? uri : Addressable::URI::parse(uri.to_s)
uri.port = (uri.scheme == "https" ? (uri.port || 443) : (uri.port || 80))

0 comments on commit fd22918

Please sign in to comment.