[#44289] [Ruby 1.9 - Feature #5128][Open] 日本語ドキュメントをUTF-8に — Shyouhei Urabe <shyouhei@...>

34 messages 2011/08/01
[#44293] [Ruby 1.9 - Feature #5128] 日本語ドキュメントをUTF-8に — Nobuyoshi Nakada <nobu@...> 2011/08/01

[#44295] Re: [ruby-dev:44293] [Ruby 1.9 - Feature #5128] 日本語ドキュメントをUTF-8に — Urabe Shyouhei <shyouhei@...> 2011/08/01

(08/01/2011 11:52 AM), Nobuyoshi Nakada wrote:

[#44299] Re: [Ruby 1.9 - Feature #5128] 日本語ドキュメントをUTF-8に — Nobuyoshi Nakada <nobu@...> 2011/08/01

なかだです。

[#44418] [Ruby 1.9 - Feature #5128] 日本語ドキュメントをUTF-8に — Ayumu AIZAWA <ayumu.aizawa@...> 2011/08/24

[#44431] Re: [ruby-dev:44418] [Ruby 1.9 - Feature #5128] 日本語ドキュメントをUTF-8に — KOSAKI Motohiro <kosaki.motohiro@...> 2011/08/27

> あいざわです

[#44443] Re: [Ruby 1.9 - Feature #5128] 日本語ドキュメントをUTF-8に — Ayumu Aizawa <ayumu.aizawa@...> 2011/09/01

あいざわです

[#44315] [Ruby 1.9 - Bug #5139][Open] sigsegv のスタックオーバフロー — Tomoyuki Chikanaga <nagachika00@...>

18 messages 2011/08/02

[#44329] [Ruby 1.9 - Bug #5151][Open] test/socket/test_socket.rb fail when udp connection failed — Ayumu AIZAWA <ayumu.aizawa@...>

16 messages 2011/08/02

[#44368] [Ruby 1.9 - Feature #5180][Open] net/http の接続時に用いる IP アドレスの指定 — Yui NARUSE <naruse@...>

15 messages 2011/08/10

[#44413] [Ruby 1.9 - Bug #5217][Open] lineno is broken when source code has about 7000 lines — Yusuke Endoh <mame@...>

11 messages 2011/08/23

[ruby-dev:44373] Re: [Ruby 1.9 - Feature #5180] net/http の接続時に用いる IP アドレスの指定

From: tadanori kojima <tadanori.kojima@...2ts.com>
Date: 2011-08-10 09:21:30 UTC
List: ruby-dev #44373
load balancer利用時のreal IPへの接続などのユースケースは理解できますが
-----
Net::HTTP.start("127.0.0.1") {|h|
  print h.request_get( '/index.html' , {"host"=>"ruby-lang.org"}).body
}

※startはIP指定、リクエスト時のhostヘッダにホスト名
-----

というのがHTTP的なふつうの対処な気がします

ホストがv4/v6の両アドレスを持つ場合などにv4で接続したい、
となるときも同じような感じでしょうか



On Wed, 10 Aug 2011 15:05:24 +0900
Yui NARUSE <naruse@airemix.jp> wrote:

> 
> Issue #5180 has been updated by Yui NARUSE.
> 
> 
> Shyouhei Urabe wrote:
> > (08/10/2011 11:46 AM), Yui NARUSE wrote:
> >  > 例えば、ホスト名は "ruby-lang.org" としたいが、IP アドレスは 127.0.0.1 とか。
> >  
> >  /etc/hostsを書け、ではだめですか。名前解決のレイヤーの要件をHTTPで解決するのは筋が悪いでしょう。
> 
> 127.0.0.1 の例だとそうなんですね。
> 
> 別のユースケースとして、同じホスト名(というかドメイン名)を持つ複数のサーバ群に対して、
> それぞれに動作確認で通信したい事があったんですが、この場合だと一定のホスト名を送りつつ 、
> IP アドレスは網羅しないといけないので、/etc/hosts だとサーバーの数だけ書き換えて試すのを
> 繰り返さないといけないのでつらいです。
> ----------------------------------------
> Feature #5180: net/http の接続時に用いる IP アドレスの指定
> http://redmine.ruby-lang.org/issues/5180
> 
> Author: Yui NARUSE
> Status: Open
> Priority: Normal
> Assignee: 
> Category: lib
> Target version: 
> 
> 
> 通常 net/http を使う時は、Net::HTTP.start("ruby-lang.org") などとホスト名を使います。
> で、Socket がホスト名から IP アドレスを引いて、コネクションが張られます。
> 普通の人はこれで足りるわけですが、ふつうな人はしばしば DNS で引けない IP アドレスに接続したくなります。
> 例えば、ホスト名は "ruby-lang.org" としたいが、IP アドレスは 127.0.0.1 とか。
> 
> 以下のパッチをあてると、
> Net::HTTP.start("ruby-lang.org", ipaddr: '127.0.0.1')
> などとできるようになります。
> 
> diff --git a/lib/net/http.rb b/lib/net/http.rb
> index 7b9ec4f..6d034e0 100644
> --- a/lib/net/http.rb
> +++ b/lib/net/http.rb
> @@ -524,7 +524,7 @@ module Net   #:nodoc:
>      # _opt_     :: optional hash
>      #
>      # _opt_ sets following values by its accessor.
> -    # The keys are ca_file, ca_path, cert, cert_store, ciphers,
> +    # The keys are ipaddr, ca_file, ca_path, cert, cert_store, ciphers,
>      # close_on_empty_response, key, open_timeout, read_timeout, ssl_timeout,
>      # ssl_version, use_ssl, verify_callback, verify_depth and verify_mode.
>      # If you set :use_ssl as true, you can use https and default value of
> @@ -542,6 +542,7 @@ module Net   #:nodoc:
>        port, p_addr, p_port, p_user, p_pass = *arg
>        port = https_default_port if !port && opt && opt[:use_ssl]
>        http = new(address, port, p_addr, p_port, p_user, p_pass)
> +      http.ipaddr = opt[:ipaddr] if opt[:ipaddr]
>  
>        if opt
>          if opt[:use_ssl]
> @@ -575,6 +576,7 @@ module Net   #:nodoc:
>      def initialize(address, port = nil)
>        @address = address
>        @port    = (port || HTTP.default_port)
> +      @ipaddr = nil
>        @curr_http_version = HTTPVersion
>        @no_keepalive_server = false
>        @close_on_empty_response = false
> @@ -620,6 +622,17 @@ module Net   #:nodoc:
>      # The port number to connect to.
>      attr_reader :port
>  
> +    # The IP address to connect to/used to connect to
> +    def ipaddr
> +      started? ?  @socket.io.peeraddr[3] : @ipaddr
> +    end
> +
> +    # Set the IP address to connect to
> +    def ipaddr=(addr)
> +      raise IOError, "ipaddr value changed, but session already started" if started?
> +      @ipaddr = addr
> +    end
> +
>      # 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
> @@ -945,7 +958,7 @@ module Net   #:nodoc:
>      # without proxy
>  
>      def conn_address
> -      address()
> +      @ipaddr || address()
>      end
>  
>      def conn_port
> 
> 
> -- 
> http://redmine.ruby-lang.org


In This Thread