Forum: Ruby-core [ruby-trunk - Feature #6617][Open] Net::HTTP: Bind to a specific local IP/port

E3f67f7ca42ef932192e81e856959baf?d=identicon&s=25 mksm (Ricardo Amorim) (Guest)
on 2012-06-21 04:16
(Received via mailing list)
Issue #6617 has been reported by mksm (Ricardo Amorim).

----------------------------------------
Feature #6617: Net::HTTP: Bind to a specific local IP/port
https://bugs.ruby-lang.org/issues/6617

Author: mksm (Ricardo Amorim)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:


Despite having several solutions floating around the net, this feature
is currently not present in Net::HTTP. I searched the issues but didn't
find any discussion on this. How does the dev team feel about this? Can
I submit a patch for revision?
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 drbrain (Eric Hodel) (Guest)
on 2012-06-22 01:44
(Received via mailing list)
Issue #6617 has been updated by drbrain (Eric Hodel).

Category set to lib

Bind to a local port like TCPSocket.new does?  I'm sure this feature
could be added.

I think the easiest way to add it would result in an API like:

  http = Net::HTTP.new remote_host
  http.local_host = local_host
  http.start do
    …
  end

Instead of passing the local host and port as parameters to
Net::HTTP.new or Net::HTTP.start.
----------------------------------------
Feature #6617: Net::HTTP: Bind to a specific local IP/port
https://bugs.ruby-lang.org/issues/6617#change-27343

Author: mksm (Ricardo Amorim)
Status: Open
Priority: Normal
Assignee:
Category: lib
Target version:


Despite having several solutions floating around the net, this feature
is currently not present in Net::HTTP. I searched the issues but didn't
find any discussion on this. How does the dev team feel about this? Can
I submit a patch for revision?
E3f67f7ca42ef932192e81e856959baf?d=identicon&s=25 mksm (Ricardo Amorim) (Guest)
on 2012-06-22 03:15
(Received via mailing list)
Issue #6617 has been updated by mksm (Ricardo Amorim).


I agree. You can pass both local_ip and local_port to TCPSocket.open in
Net::HTTP#connect.

Having the setter exposed would allow the user to change the local IP
address between connections. Any ideas if this could cause problems with
Net::HTTP or remote servers? There's also proxy and ipv6 support, both
which I have never tested using this approach.
----------------------------------------
Feature #6617: Net::HTTP: Bind to a specific local IP/port
https://bugs.ruby-lang.org/issues/6617#change-27351

Author: mksm (Ricardo Amorim)
Status: Open
Priority: Normal
Assignee:
Category: lib
Target version:


Despite having several solutions floating around the net, this feature
is currently not present in Net::HTTP. I searched the issues but didn't
find any discussion on this. How does the dev team feel about this? Can
I submit a patch for revision?
E3f67f7ca42ef932192e81e856959baf?d=identicon&s=25 mksm (Ricardo Amorim) (Guest)
on 2012-06-25 20:44
(Received via mailing list)
Issue #6617 has been updated by mksm (Ricardo Amorim).

File net-http_bind_to_local_ip.patch added

The patch adds accessors for @local_host and @local_port and uses both
in TCPSocket.open call.
----------------------------------------
Feature #6617: Net::HTTP: Bind to a specific local IP/port
https://bugs.ruby-lang.org/issues/6617#change-27417

Author: mksm (Ricardo Amorim)
Status: Open
Priority: Normal
Assignee:
Category: lib
Target version:


Despite having several solutions floating around the net, this feature
is currently not present in Net::HTTP. I searched the issues but didn't
find any discussion on this. How does the dev team feel about this? Can
I submit a patch for revision?
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 drbrain (Eric Hodel) (Guest)
on 2012-06-25 23:46
(Received via mailing list)
Issue #6617 has been updated by drbrain (Eric Hodel).

Assignee set to naruse (Yui NARUSE)
Target version set to 2.0.0


----------------------------------------
Feature #6617: Net::HTTP: Bind to a specific local IP/port
https://bugs.ruby-lang.org/issues/6617#change-27453

Author: mksm (Ricardo Amorim)
Status: Open
Priority: Normal
Assignee: naruse (Yui NARUSE)
Category: lib
Target version: 2.0.0


Despite having several solutions floating around the net, this feature
is currently not present in Net::HTTP. I searched the issues but didn't
find any discussion on this. How does the dev team feel about this? Can
I submit a patch for revision?
9361878d459f1709feec780518946ee5?d=identicon&s=25 naruse (Yui NARUSE) (Guest)
on 2012-07-03 06:14
(Received via mailing list)
Issue #6617 has been updated by naruse (Yui NARUSE).


It looks good.
Could you provide a test for it?
It should be a patch for test/net/http/test_http.rb
----------------------------------------
Feature #6617: Net::HTTP: Bind to a specific local IP/port
https://bugs.ruby-lang.org/issues/6617#change-27740

Author: mksm (Ricardo Amorim)
Status: Open
Priority: Normal
Assignee: naruse (Yui NARUSE)
Category: lib
Target version: 2.0.0


Despite having several solutions floating around the net, this feature
is currently not present in Net::HTTP. I searched the issues but didn't
find any discussion on this. How does the dev team feel about this? Can
I submit a patch for revision?
Ca4a2f5faead6e957adb5caf34d5107f?d=identicon&s=25 madeofcode (Mark Dodwell) (Guest)
on 2012-07-04 12:07
(Received via mailing list)
Issue #6617 has been updated by madeofcode (Mark Dodwell).


Forgive me if this is a silly question, but what is the point of
initializing the instance variables to nil in the initializer?
----------------------------------------
Feature #6617: Net::HTTP: Bind to a specific local IP/port
https://bugs.ruby-lang.org/issues/6617#change-27792

Author: mksm (Ricardo Amorim)
Status: Open
Priority: Normal
Assignee: naruse (Yui NARUSE)
Category: lib
Target version: 2.0.0


Despite having several solutions floating around the net, this feature
is currently not present in Net::HTTP. I searched the issues but didn't
find any discussion on this. How does the dev team feel about this? Can
I submit a patch for revision?
E8a419959139f3f505b49bb95f7e7afe?d=identicon&s=25 Joshua Ballanco (jballanc)
on 2012-07-04 17:06
(Received via mailing list)
Issue #6617 has been updated by jballanc (Joshua Ballanco).


=begin
Not sure, but it may be related to this:

    >> defined?(@foo)
    => nil
    >> @foo = nil
    => nil
    >> defined?(@foo)
    => "instance-variable"

=end

----------------------------------------
Feature #6617: Net::HTTP: Bind to a specific local IP/port
https://bugs.ruby-lang.org/issues/6617#change-27808

Author: mksm (Ricardo Amorim)
Status: Open
Priority: Normal
Assignee: naruse (Yui NARUSE)
Category: lib
Target version: 2.0.0


Despite having several solutions floating around the net, this feature
is currently not present in Net::HTTP. I searched the issues but didn't
find any discussion on this. How does the dev team feel about this? Can
I submit a patch for revision?
E3f67f7ca42ef932192e81e856959baf?d=identicon&s=25 mksm (Ricardo Amorim) (Guest)
on 2012-07-05 07:20
(Received via mailing list)
Issue #6617 has been updated by mksm (Ricardo Amorim).

File net-http_bind_to_local_ip-tests.patch added

@naruse: tests attached! It seems that local_host cannot be nil when
setting local_port in TCPSocket.open.

@madeofcode: I also do not know, just followed the pattern. jballanc may
have a point, but i can't see why there would be #defined? checks on
ivars.

----------------------------------------
Feature #6617: Net::HTTP: Bind to a specific local IP/port
https://bugs.ruby-lang.org/issues/6617#change-27822

Author: mksm (Ricardo Amorim)
Status: Open
Priority: Normal
Assignee: naruse (Yui NARUSE)
Category: lib
Target version: 2.0.0


Despite having several solutions floating around the net, this feature
is currently not present in Net::HTTP. I searched the issues but didn't
find any discussion on this. How does the dev team feel about this? Can
I submit a patch for revision?
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 drbrain (Eric Hodel) (Guest)
on 2012-07-05 21:49
(Received via mailing list)
Issue #6617 has been updated by drbrain (Eric Hodel).


=begin
You need to initialize instance variables to prevent warnings on
uninitialized access:

  $ ruby -we 'p @x'
  -e:1: warning: instance variable @x not initialized
  nil
=end

----------------------------------------
Feature #6617: Net::HTTP: Bind to a specific local IP/port
https://bugs.ruby-lang.org/issues/6617#change-27835

Author: mksm (Ricardo Amorim)
Status: Open
Priority: Normal
Assignee: naruse (Yui NARUSE)
Category: lib
Target version: 2.0.0


Despite having several solutions floating around the net, this feature
is currently not present in Net::HTTP. I searched the issues but didn't
find any discussion on this. How does the dev team feel about this? Can
I submit a patch for revision?
This topic is locked and can not be replied to.