I need to implement an HTTP proxy in Django, and my google safari led me to a project called django-webproxy .
Although it is no longer supported, it is quite simple. Most of the logic relies on a simple Middleware proxy that intercepts all requests to the Django WSGI server and processes it.
If Middleware returns any data, the WSGI server simply passes it back to the client, but if it does not return anything, Django simply processes the request, moving to another middleware.
Everything works fine, to a large extent, but I need to implement proxy authentication, which means I have to send the 407 status code to the client with the header Proxy-Authenticate. This sin't is resolved by Django as it is the hop-by-hop header and Django is the exception. How can I hack / force / kludge Django to allow me to send hop-by-hop headers?
FYI, the code for the middleware class can be found here .
source
share