Project

General

Profile

net-http_bind_to_local_ip.patch

mksm (Ricardo Amorim), 06/26/2012 03:44 AM

View differences:

lib/net/http.rb
587 587
    def initialize(address, port = nil)
588 588
      @address = address
589 589
      @port    = (port || HTTP.default_port)
590
      @local_host = nil
591
      @local_port = nil
590 592
      @curr_http_version = HTTPVersion
591 593
      @keep_alive_timeout = 2
592 594
      @last_communicated = nil
......
631 633
    # The port number to connect to.
632 634
    attr_reader :port
635
    # The local host used to estabilish the connection.
636
    attr_accessor :local_host
637

  
638
    # The local port used to estabilish the connection.
639
    attr_accessor :local_port
640

  
633 641
    # Number of seconds to wait for the connection to open. Any number
634 642
    # may be used, including Floats for fractional seconds. If the HTTP
635 643
    # object cannot open a connection in this many seconds, it raises a
......
799 807
    def connect
800 808
      D "opening connection to #{conn_address()}..."
801 809
      s = Timeout.timeout(@open_timeout, Net::OpenTimeout) {
802
        TCPSocket.open(conn_address(), conn_port())
810
        TCPSocket.open(conn_address(), conn_port(), @local_host, @local_port)
803 811
      }
804 812
      D "opened"
805 813
      if use_ssl?