I\'m trying to print out the body of a HTTP response using Python.
Here is my code sofar:
from twisted.web import proxy, http
from twisted.internet i
Override the dataReceived method of a protocol (proxy.Proxy in your case) and handle the data modification in that method:
from twisted.web import proxy, http
from twisted.internet import reactor
from twisted.python import log
import sys
log.startLogging(sys.stdout)
class MyProxy(proxy.Proxy):
def dataReceived(self, data):
# Modify the data here
print data
# perform the default functionality on modified data
return proxy.Proxy.dataReceived(self, data)
class ProxyFactory(http.HTTPFactory):
protocol=MyProxy
factory = ProxyFactory()
reactor.listenTCP(8080, factory)
reactor.run()