Http io?

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.

···

-----Original Message-----
From: Horacio Sanson [mailto:hsanson@moegi.waseda.jp]
Sent: Wednesday, 16 November 2005 5:53 PM
To: ruby-talk ML
Subject: Re: HTTP IO??

Does a verbatim copy of this code work?? I really don't
understand what it does but that code gives me syntax errors

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

Horacio

Wednesday 16 November 2005 15:30、Daniel Sheppard さんは書きました:
> Well, I'd advise reading
>
>
http://redhanded.hobix.com/inspect/theStoryOfStreamingHttpThroughMouse
> ho leWithSubsequentAdventuresInContinuationsAndDuckTyping.html
>
> And using the code there for the HTTPIO object. It's what works for
> mousehole, which I've been using quite happily as my
internet proxy,
> so I guess that the HTTPIO object works.
>
> Now the question is, what are you actually doing. Then we
can probably
> figure out what's wrong. Now, _why's code doesn't make an actual IO
> object - just one that looks sufficiently like an IO object for the
> Webrick to be convinced to use the read method - he's got a
specific
> use-case, and crammed the object to work in that situation. It
> probably wont work in yours without further tweaking.
>
> > -----Original Message-----
> > From: Horacio Sanson [mailto:hsanson@moegi.waseda.jp]
> > Sent: Wednesday, 16 November 2005 4:56 PM
> > To: ruby-talk ML
> > Subject: HTTP IO??
> >
> >
> > I am developing a streaming client in ruby, so far so good...
> > now I am trying to get Net::HTTP to behave like an IO
with no luck.
> > I need Net::HTTP to read the headers as it usually does
but stop at
> > before reading the body of the page so I can read the stream in
> > chunks and feed them to the player.
> >
> > I read this article
> >
> > http://redhanded.hobix.com/inspect/theStoryOfStreamingHttpThro
> >
ughMouseholeWithSubsequentAdventuresInContinuationsAndDuckTyping.htm
> > l
> >
> > but I can't get it to work.
> >
> > any help is appreciated.....
> >
> > Horacio
>
>
>#############################################################
##########
>#### ########## This email has been scanned by MailMarshal, an email
>content filter.
>
>#############################################################
##########
>####
>##########

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

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

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: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:58、Daniel Sheppard さんは書きました:

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

http://rubyforge.org/cgi-bin/viewcvs.cgi/mouseHole/lib/net/httpio.rb?cvsroo
t=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.

> -----Original Message-----
> From: Horacio Sanson [mailto:hsanson@moegi.waseda.jp]
> Sent: Wednesday, 16 November 2005 5:53 PM
> To: ruby-talk ML
> Subject: Re: HTTP IO??
>
>
> Does a verbatim copy of this code work?? I really don't
> understand what it does but that code gives me syntax errors
>
> 316: syntax error def read len = nil; ... end
>
> Horacio
>
> Wednesday 16 November 2005 15:30、Daniel Sheppard さんは書きました:
> > Well, I'd advise reading
>
> http://redhanded.hobix.com/inspect/theStoryOfStreamingHttpThroughMouse
>
> > ho leWithSubsequentAdventuresInContinuationsAndDuckTyping.html
> >
> > And using the code there for the HTTPIO object. It's what works for
> > mousehole, which I've been using quite happily as my
>
> internet proxy,
>
> > so I guess that the HTTPIO object works.
> >
> > Now the question is, what are you actually doing. Then we
>
> can probably
>
> > figure out what's wrong. Now, _why's code doesn't make an actual IO
> > object - just one that looks sufficiently like an IO object for the
> > Webrick to be convinced to use the read method - he's got a
>
> specific
>
> > use-case, and crammed the object to work in that situation. It
> > probably wont work in yours without further tweaking.
> >
> > > -----Original Message-----
> > > From: Horacio Sanson [mailto:hsanson@moegi.waseda.jp]
> > > Sent: Wednesday, 16 November 2005 4:56 PM
> > > To: ruby-talk ML
> > > Subject: HTTP IO??
> > >
> > >
> > > I am developing a streaming client in ruby, so far so good...
> > > now I am trying to get Net::HTTP to behave like an IO
>
> with no luck.
>
> > > I need Net::HTTP to read the headers as it usually does
>
> but stop at
>
> > > before reading the body of the page so I can read the stream in
> > > chunks and feed them to the player.
> > >
> > > I read this article
> > >
> > > http://redhanded.hobix.com/inspect/theStoryOfStreamingHttpThro
>
> ughMouseholeWithSubsequentAdventuresInContinuationsAndDuckTyping.htm
>
> > > l
> > >
> > > but I can't get it to work.
> > >
> > > any help is appreciated.....
> > >
> > > Horacio
> >
> >#############################################################
>
> ##########
>
> >#### ########## This email has been scanned by MailMarshal, an email
> >content filter.
> >
> >#############################################################
>
> ##########
>
> >####
> >##########
>
> ##############################################################
> #######################
> This email has been scanned by MailMarshal, an email content filter.
> ##############################################################
> #######################

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