Re: HTTP IO?


#1

the … implies the missing code. Grab the whole thing from:

http://rubyforge.org/cgi-bin/viewcvs.cgi/mouseHole/lib/net/httpio.rb?cvsroot=mousehole

The read and close method should work the same as the read and close
methods on IO. Any other IO methods that you’d like supported, you’ll
need to add yourself.

316: syntax error def read len = nil; … end

specific

I am developing a streaming client in ruby, so far so good…

#############################################################
#######################
This email has been scanned by MailMarshal, an email content filter.
##############################################################
#######################

#####################################################################################
This email has been scanned by MailMarshal, an email content filter.
#####################################################################################


#2

Sorry to bother so much… I still have problems…

this code
######################################
url = URI.parse(“http://www.ruby-doc.org”)
req = Net::HTTP::Get.new(url.request_uri || “/”)
resp = Net::HTTPIO.start(url.host, url.port) { |http|
http.request(req)
}

if resp.kind_of?Net::HTTPSuccess

resp.each_header { |key, val|
	puts " #{key}: #{val}"
}

sleep(2)
data=resp.read(1024)
puts data
data=resp.read(1024)
puts data
data=resp.read
puts data
data=resp.read
puts data

else
puts “Error accessing server”
end
########################################

Reading consecutive times from the resp object gives an error. This
doesnt
happen at the same read, for example some times I get to call read two
times
and the error appears, sometimes only once, etc. Seems random.

this is the error

############################################3
/usr/lib/ruby/1.8/net/protocol.rb:133:in sysread': closed stream (IOError) from /usr/lib/ruby/1.8/net/protocol.rb:133:inrbuf_fill’
from /usr/lib/ruby/1.8/timeout.rb:45:in timeout' from /usr/lib/ruby/1.8/timeout.rb:62:intimeout’
from /usr/lib/ruby/1.8/net/protocol.rb:132:in rbuf_fill' from /usr/lib/ruby/1.8/net/protocol.rb:86:inread’
from oggtest.rb:301:in `read’
from oggtest.rb:382

##############################################

I am reading the stream from a Ogg stream server (VLC) in the local
machine.
This requires fast reading.

Are there any other options in ruby to read a data stream via HTTP??

regards,
Horacio

Wednesday 16 November 2005 15:58e$B!"e(BDaniel S.
e$B$5$s$O=q$-$^$7$?e(B: