[Twisted-web] Fwd: Web-Based Proxy
davefowler at gmail.com
Mon Jul 20 13:01:22 EDT 2009
Ok, I've read the entire Twisted O'Reilly book and gone through many of the
docs and tutorials but I still need a bit of direction.
I'm trying to make a simple web-based proxy. Similar to the proxy in the
Twisted book, but with a web interface. So I could go to
http://asdf.com.MYPROXYSITE.com and see the contents of asdf.com.
I have the following code that works well as a browser proxy, but I need to
figure out how make it web based.
My thoughts are that I need to make an HTTP server and then adjust the
address in the protocol before finishing the proxy request. Am I on the
right track? Does anyone have examples of this?
Should I ditch the Proxy classes all together?
Thanks for any input.
from twisted.web import proxy, http
from twisted.python import log
def __init__(self, *args):
print "inside Proxy"
print "Proxy: ", self.__dict__
class ProxyFactory(http.HTTPFactory): # Receive connections from the client
""" Receives connections from the client """
def __init__(self): # This function only needed for printing input and
print "inside proxy factory"
def buildProtocol(self, addr):
protocol = Proxy()
print "making protocol for addr", addr
print "protocol:", protocol.__dict__
if __name__ == "__main__":
PROXY_PORT = 8001
from twisted.internet import reactor
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-web