[Twisted-Python] recommended starting point for http debugging/logging proxy.

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Fri Oct 8 09:28:32 EDT 2010


On 7 Oct, 07:48 pm, gelonida at gmail.com wrote:
>Hi,
>
>
>Can anybody recommend  a good starting point for a twisted http proxy,
>or comment on the links that I'll mention lateron in this post?

The source for twisted.web.proxy is pretty short, only a couple hundred 
lines.  If you want to use it but hook into parts of the 
request/response process, then taking a look at the implementation is 
probably a good idea.

To make sense of it, you probably want to read at least the client and 
server howtos on the Twisted site:

    http://twistedmatrix.com/documents/current/core/howto/servers.html
    http://twistedmatrix.com/documents/current/core/howto/clients.html
>I'd like to use a ddebugging it for playing/debugging/filtering
>
>Initially I'd just like to log all requests.

If you pass a logPath argument to HTTPFactory, it will log requests to 
that path.

Jean-Paul
>lateron I'd like to save certain responses on the disk.
>
>Please note:
>Im familiar with python and http / html in general.
>
>I'm not experienced with twisted, but thought, that this might be a 
>good
>example / excuseto learn a little.
>
>I found following links and wondered what you could recommend:
>
>http://defrang.com/python mentions a HTTP Debugging Proxy
>---------------------------------------------------------
>
>http://wiki.python.org/moin/Twisted-Examples has following example, but
>I dont't know where to hook in:
>
>I found one twisted example for a web proxy, but it was so simple, that
>I don''t have any idea of where to hook in.
>
>from twisted.web import proxy, http
>from twisted.internet import reactor
>from twisted.python import log
>import sys
>log.startLogging(sys.stdout)
>
>class ProxyFactory(http.HTTPFactory):
>    protocol = proxy.Proxy
>
>reactor.listenTCP(8080, ProxyFactory())
>reactor.run()
>
>-------------------------------------------------------------
>
>
>http://sujitpal.blogspot.com/2010/03/http-debug-proxy-with-twisted.html
>
>
>seems also interesting



More information about the Twisted-Python mailing list