Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [WEBrick] streaming output

Reply
Thread Tools

[WEBrick] streaming output

 
 
Dan Janowski
Guest
Posts: n/a
 
      11-29-2004
Is there a way to send a stream of output while processing, I want to
send ongoing status? The basic response construct seems to want the
output in a finalized form. The clients will render progressively from
what I understand.

Dan



 
Reply With Quote
 
 
 
 
GOTOU Yuuzou
Guest
Posts: n/a
 
      11-29-2004
In message <812ABBE6-4255-11D9-AF7F->,
`Dan Janowski <>' wrote:
> Is there a way to send a stream of output while processing, I want to
> send ongoing status? The basic response construct seems to want the
> output in a finalized form. The clients will render progressively from
> what I understand.


Set an IO to res.body, and write data from another thread.

require "webrick"

class Streamlet < WEBrick::HTTPServlet::AbstractServlet
def do_GET(req, res)
res["content-type"] = "application/octet-stream"
r, w = IO.pipe
res.body = r
Thread.start{
10.times{|i|
w.write("#{i}" * 4096)
sleep(1)
}
w.close
}
end
end

httpd = WEBrick::HTTPServer.new(ort=>10080)
httpd.mount("/", Streamlet)
trap(:INT){ httpd.shutdown }
httpd.start

--
gotoyuzo


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I read streaming output of a subprocess Damjan Georgievski Python 2 05-02-2012 02:51 PM
stiff dicks stilesproject streaming media host streaming mediasolutions streaming media funduk Java 0 11-04-2008 12:35 PM
System commands with streaming output Alex Wayne Ruby 8 04-08-2008 11:47 PM
Output streaming of a servlet anu Java 2 03-14-2007 11:41 PM
How to on word doc output (page setup, streaming html and datagrid, open file) Andrew ASP .Net 1 10-05-2005 02:57 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57