# Re: HTTP IO?

**URL:** <https://www.ruby-forum.com/t/re-http-io/102500>\
**Category:** Ruby\
**Created:** [November 16, 2005, 8:01am UTC](https://www.ruby-forum.com/t/re-http-io/102500 "2005-11-16T08:01:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniels](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3ab097/32.png) [@daniels](https://www.ruby-forum.com/u/daniels)\
**Post date:** [November 16, 2005, 8:01am UTC](https://www.ruby-forum.com/t/re-http-io/102500/1 "2005-11-16T08:01:31Z")

</div>

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

[http://rubyforge.org/cgi-bin/viewcvs.cgi/mouseHole/lib/net/httpio.rb?cvsroot=mousehole](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.  
#####################################################################################

---

<div class="post-metadata">

**Author:** ![daniels](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3ab097/32.png) [@daniels](https://www.ruby-forum.com/u/daniels)\
**Post date:** [November 16, 2005, 9:28am UTC](https://www.ruby-forum.com/t/re-http-io/102500/2 "2005-11-16T09:28:54Z")

</div>

Sorry to bother so much… I still have problems…

this code  
######################################  
url = URI.parse(“[http://www.ruby-doc.org](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:in `rbuf\_fill’  
from /usr/lib/ruby/1.8/timeout.rb:45:in `timeout' from /usr/lib/ruby/1.8/timeout.rb:62:in `timeout’  
from /usr/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill' from /usr/lib/ruby/1.8/net/protocol.rb:86:in `read’  
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:
