benoitc/restkit — pull request #124 by alanjds (2013-04-29 04:50:06+00:00)
Title: New: Proxy with PEP 333-compliant chunked-response support (based on Paste's Proxy class)

I tried to figure out some bug about partial responses using `HostProxy`. It occur on requests that works fine with Paste's [Proxy](http://pythonpaste.org/modules/proxy.html#paste.proxy.Proxy) middleware. Finally, I found the problem to be the HostProxy implementation of chunked responses.

By some PEP 333 [chapter](http://www.python.org/dev/peps/pep-0333/#handling-the-content-length-header), only the server MAY add chunked responses headers, but it usually does so only if Content-Length is not set. At least Gunicorn seems to do chunked very fine, if no Content-Length is set, AFAIK.

So, I copied over `paste.proxy.Proxy` code as a new starting point and adapted to use restkit client and to allow streaming of the client response.

This works very good for me. I added no tests, but its working over my blog http://kombobreaker.com/blog

I dont know where the new class should be: wsgi_proxy.py or a new module?
Waiting for your feedback and/or merge.