[Mongrel] Streaming content

Ry Dahl ry at tinyclouds.org
Tue Mar 27 10:15:54 EDT 2007


If attempting to circumvent a web server's writing procedures, be sure
to send the HTTP headers yourself!

(i'm an idiot)

thanks for listening,
ry


On 3/26/07, Ry Dahl <ry at tinyclouds.org> wrote:
> Hello
>
> I'm attempting to write a mongrel plug-in which would stream a response.
>
> At first I was doing this
>
>   def process(request, response)
>     response.start do |head,out|
>       head['Content-Type'] = 'text/html'
>       %w{o m g}.each { |c|  out.puts c; sleep 5; }
>     end
>     response.done = true
>   end
>
> But then I looked at HttpResponse and decided that this probably isn't
> sending anything to the socket while I'm in the OMG loop:
>
>     def start(status=200, finalize=false)
>       @status = status.to_i
>       yield @header, @body
>       finished if finalize
>     end
>
> So I thought using HttpResponse#write might work -
>
>   def process(request, response)
>     %w{o m g}.each { |c| response.write(c); sleep 5; }
>     response.done = true
>   end
>
> but that also didn't work. How can I stream content?
>
> THANKS!
>


-- 
+1.760.536.4191


More information about the Mongrel-users mailing list