0

Reverse proxy capable pure python webserver?

References twisted, and there is a great example for how to set up a reverse proxy, that appears to work. I could not find how to make the example collect all the chunks and send off an unchunked request to the upstream server, like happens with the default nginx reverse proxy config. Is that possible with twisted? Some other pure python project?

from twisted.internet import reactor
from twisted.web import proxy, server

site = server.Site(proxy.ReverseProxyResource('localhost', 8002, b''))
reactor.listenTCP(8081, site)
reactor.run()
AntonOfTheWoods
  • 809
  • 13
  • 17
  • Twisted has code to handle chunks, so you could probably watch for `Transfer-Encoding: chunked` and process accordingly. The 'cheating way' I've seen other proxies use is to explicitly set the request protocol to `HTTP/1.0` so that chunking never happens. – match Oct 22 '20 at 11:22
  • Alas, I don't control the clients and am reproducing a proprietary API that only does 1.1+ – AntonOfTheWoods Oct 25 '20 at 14:55

0 Answers0