I came across this simple proxy example that uses Twisted:
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
from twisted.internet import reactor
from twisted.web import proxy, server
site = server.Site(proxy.ReverseProxyResource('yahoo.com', 80, ''))
reactor.listenTCP(8080, site)
reactor.run()
The issue is that my computer needs to use a proxy itself to access the web, so I was wondering if there is a way to specify those proxy settings?
Not really. At least, there's not an easy way to do it with Twisted.
ReverseProxyResource
delegates toReverseProxyRequest
which does a direct TCP connection to the specified host (in this case, yahoo.com).You could probably cobble something together by adapting
ReverseProxyRequest
to usetwisted.web.client.ProxyAgent
. Arguably, Twisted itself should provide a way to parametrizeReverseProxyResource
by agent.