From: "NAKAMURA, Hiroshi" Date: 1999-06-09T12:32:36+09:00 Subject: [ruby-list:14945] Re: HTTP Client with Ruby なひです. > From: Takahiro Maebashi [mailto:maebashi@iij.ad.jp] > Sent: Wednesday, June 09, 1999 11:35 AM > > http-access-0.0.1のPatch作ってみました. > > > @@ -179,6 +185,11 @@ > > else > > read_body(maxbytes) > > end > > + if @next_connection > > + @state = :WAIT > > + else > > + close > > + end > > end > > get_data はブロックなしで呼び出されることもあるので、このままだと一度 > get_data を呼び出したら途端に切れてしまうと思うのでまずいんじゃないでしょ > うか。 なるほど,get_dataはそういうことになっていたんですね... Persistent Connectionsはchunkedなデータでしかテストしてなかったので, 「blockなしget_dataは全部まとめて取ってくる」なのかと勘違いしてました. READMEをちゃんと読まずにPatch作っちゃいました.ごめんなさい. で,恥の上継ぎ(?),追加Patchです.こんな感じかな? # なひは上述のありさまなので,あまり信用しないでください > 高橋さん ^^; diff -ur http-access-0.0.1.p1/http-access.rb http-access-0.0.1/http-access.rb --- http-access-0.0.1.p1/http-access.rb Wed Jun 9 12:16:37 1999 +++ http-access-0.0.1/http-access.rb Wed Jun 9 12:20:44 1999 @@ -183,13 +183,15 @@ block.call(read_body(maxbytes)) end else - read_body(maxbytes) + data = read_body(maxbytes) + return data unless eof? end if @next_connection @state = :WAIT else close end + nil end def read_body(maxbytes=nil) @@ -282,5 +284,8 @@ h.request_get(url.path, 'User-Agent'=>'FooBar/1.0') h.get_response h.get_header {|line| p line} - h.get_data(8192) {|data| p data} + str = "" + while ( str = h.get_data( 10 )) + p str + end end