0

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?

astrofrog
  • 29,833
  • 28
  • 86
  • 128

1 Answers1

0

Not really. At least, there's not an easy way to do it with Twisted.

ReverseProxyResource delegates to ReverseProxyRequest 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 use twisted.web.client.ProxyAgent. Arguably, Twisted itself should provide a way to parametrize ReverseProxyResource by agent.

jml
  • 975
  • 1
  • 7
  • 20