From: ara.t.howard@... Date: 2007-01-19T00:45:40+09:00 Subject: Re: Reading an HTTPResponse line by line On Fri, 19 Jan 2007, Scara Maccai wrote: > Hi, > how can I read a response from an http server line by line? > > req = Net::HTTP.new('10.2.1.2') > res = req.post('/mycgi', mydata) do |str| > print str > end > > How can I read a line instead of a "chunck" of data in str? > Something like "BufferedReader.readLine()" in Java... > harp:~ > cat a.rb require 'stringio' sio = StringIO.new req = Net::HTTP.new '10.2.1.2' mydata = '' res = req.post('/mycgi', mydata){|str| sio << str} sio.rewind sio.each{|line| p line} -a -- in the practice of tolerance, one's enemy is the best teacher. - the dalai lama