[web-devel] Advice on implementing a web proxy

Erik de Castro Lopo mle+hs at mega-nerd.com
Thu Dec 8 07:55:19 CET 2011


Michael Snoyman wrote:

> > Unfortunately, no. This is listed as one of the know problems
> > in the readme file:
> >
> >    https://github.com/erikd/http-proxy/blob/master/README.txt
> >
> > I my opinion, the way to fix this is to modify and extend Wai.
> > I too would like to see this problem solved but its lower
> > priority than some of the other things I want to address.
> 
> Can you point me to the code that demonstrates this?

Hmm, I came to this conclusion some time ago and the actual
code seems to be different from how I remember it. However,
there is still a problem.

The problem is that the Wai.Request structure

    http://hackage.haskell.org/packages/archive/wai/0.4.2/doc/html/src/Network-Wai.html#Response

has no requestBody field. A HTTP POST operation contains HTTP
request headers (with a Content-Length header) and a request
body. The Content-Type field of the header can specify things
like text/xml or application/x-www-form-urlencoded.

For Kazu Yamamoto's case, I think he would like to be able
to handle bit small POST request bodies (1k or so) but also
very large onces (hundreds ot Meg or more). The the case where
the POST body is large, we would not want Warp to try and suck
the whole thing into memory before passing it to the server.

I would also find the above useful. I think all that is required
is the addition of a requestBody field that works much like the
responseBody file in the Warp.Response structure.

Cheers,
Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/



More information about the web-devel mailing list