[web-devel] Advice on implementing a web proxy

Erik de Castro Lopo mle+hs at mega-nerd.com
Mon Nov 28 11:12:40 CET 2011

Kazu Yamamoto (山本和彦) wrote:

> You use parseURL. It returns Request whose requestBody is
> RequestBodyLBS L.empty. This means that your code does not
> relay HTTP body at all.

You are correct. So far I have really only tested this with
http GET requests. Fixing that should be trivial.

> I'm now implementing a reverse proxy. I tested several ways to realy
> HTTP body but only one solution which works is to get whole HTTP body
> as ByteString and specify it to RequestBodyLBS. This is
> store-and-forward, not pipelining.
> My code can be found:
> 	https://github.com/kazu-yamamoto/wai-app-file-cgi/blob/master/Network/Wai/Application/Classic/RevProxy.hs
> I'm wondering if Enumerator can implement pipelining...

It definitely can. Have a a look at the function serveRequest in
this file:


On a machine with 4Gig of RAM, I have simultaneous downloaded 4
copies of a 4Gig DVD ISO through my proxy, with memory usage
never going above about 10%.

I'm going right back to basics to try and get a really good understanding
of Enumerators and Iteratees.

Erik de Castro Lopo

More information about the web-devel mailing list