[Twisted-Python] Twisted n00b question
Michal Migurski
mike at stamen.com
Mon Jan 23 17:01:17 EST 2006
Hello -
I'm completely new to Twisted and moderately (~1 year) experienced
with Python, and I'm here because I need some help understanding how
to set up a web proxy.
My goal: an HTTP proxy living on my local machine (OS X) that will
transparently serve up web pages to myself, while allowing me to
snoop & log connections I make to remote servers. I want the
equivalent of an Attention Trust recorder (http://
www.attentiontrust.org/services) without having to use Firefox.
My first attempt: using the demonstration service.tac as a starting
point, I wrote a new Resource that can view the request. I got far
enough to look inside the request object passed to my resource's
render() method, and return a meaningful response showing that I was
seeing accurate request information. So in that render() method, I
generate a new HTTPClientFactory object which *should* be able to
make a request the intended server and return the results. I stopped
when I realized the documentation showed examples using reactor.run
(), while advising that I should never actually use reactor.run() in
a real app. So I'm stuck trying to generate a new http client
request while inside an http server.
My second attempt: I found the Proxy class in the twisted.web docs,
which has this code snippet:
from twisted.protocols import http
f = http.HTTPFactory()
f.protocol = Proxy
...which is great, but I'm now I'm not sure what I need to do with
the "f" object to make it work in a .tac/twistd context. It seems
like should be able to add a callback in there someplace to intercept
the proxied requests and pick them apart, but I'm a little stuck.
Thanks in advance for any pointers or examples that may help.
-mike.
----------------------------------------------------------------
michal migurski- mike at stamen.com
415.558.1610
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20060123/27b3a2d0/attachment.htm
More information about the Twisted-Python
mailing list