# Webrick proxy server and streaming

**URL:** <https://rubytalk.org/t/webrick-proxy-server-and-streaming/49096>\
**Category:** ruby-talk\
**Created:** [15 September 2008 14:27 UTC](https://rubytalk.org/t/webrick-proxy-server-and-streaming/49096 "2008-09-15T14:27:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Googy](https://avatars.discourse-cdn.com/v4/letter/g/dfb087/32.png) [@Googy](https://rubytalk.org/u/Googy)\
**Post date:** [15 September 2008 14:27 UTC](https://rubytalk.org/t/webrick-proxy-server-and-streaming/49096/1 "2008-09-15T14:27:52Z")

</div>

Hi,

I ran webrick proxy server snippet found on [webrick.org](http://webrick.org) site. It was  
working fine except with streaming or large files. Rather than handing  
over data to browser as it gets it downloading entire file and then  
flushing entire file to client. Is it possible to webrick to hand  
over data to client as it gets ?, So that streaming and progressive  
loading at client side work as expected ?

#!/usr/local/bin/ruby  
require 'webrick/httpproxy'

s = WEBrick::HTTPProxyServer.new(  
&nbsp;&nbsp;:Port =\> 2020,  
&nbsp;&nbsp;:RequestCallback =\> Proc.new{|req,res|  
&nbsp;&nbsp;&nbsp;&nbsp;puts "-"\*70  
&nbsp;&nbsp;&nbsp;&nbsp;puts req.request\_line, req.raw\_header  
&nbsp;&nbsp;&nbsp;&nbsp;puts "-"\*70  
&nbsp;&nbsp;}  
)  
trap("INT"){ s.shutdown }  
s.start

---

<div class="post-metadata">

**Author:** ![Googy](https://avatars.discourse-cdn.com/v4/letter/g/dfb087/32.png) [@Googy](https://rubytalk.org/u/Googy)\
**Post date:** [15 September 2008 14:37 UTC](https://rubytalk.org/t/webrick-proxy-server-and-streaming/49096/2 "2008-09-15T14:37:48Z")

</div>

BTW you can use youtube for testing streaming behavior.

> **···**
>
> On Sep 15, 7:32 pm, samba \<cooldudevam...@gmail.com\> wrote:
> 
> > Hi,
> > 
> > I ran webrick proxy server snippet found on webrick.org site. It was  
> > working fine except with streaming or large files. Rather than handing  
> > over data to browser as it gets it downloading entire file and then  
> > flushing entire file to client. Is it possible to webrick to hand  
> > over data to client as it gets ?, So that streaming and progressive  
> > loading at client side work as expected ?
> > 
> > #!/usr/local/bin/ruby  
> > require 'webrick/httpproxy'
> > 
> > s = WEBrick::HTTPProxyServer.new(  
> > :Port =\> 2020,  
> > :RequestCallback =\> Proc.new{|req,res|  
> > puts "-"\*70  
> > puts req.request\_line, req.raw\_header  
> > puts "-"\*70  
> > }  
> > )  
> > trap("INT"){ s.shutdown }  
> > s.start
