Skip to content

Instantly share code, notes, and snippets.

@zodman
Created November 23, 2010 21:20
Show Gist options
  • Save zodman/712561 to your computer and use it in GitHub Desktop.
Save zodman/712561 to your computer and use it in GitHub Desktop.
fliddler.py
from twisted.internet import reactor
from twisted.web import http
from twisted.web.proxy import Proxy, ProxyRequest, ProxyClientFactory, ProxyClient
class InterceptingProxyClient(ProxyClient):
def handleResponsePart(self, buffer):
if 'x-requested-with' in self.headers.keys():
print(buffer)
ProxyClient.handleResponsePart(self, buffer)
class InterceptingProxyClientFactory(ProxyClientFactory):
protocol = InterceptingProxyClient
class InterceptingProxyRequest(ProxyRequest):
protocols = {'http': InterceptingProxyClientFactory}
def process(self):
ProxyRequest.process(self)
class InterceptingProxy(Proxy):
requestFactory = InterceptingProxyRequest
factory = http.HTTPFactory()
factory.protocol = InterceptingProxy
reactor.listenTCP(8001, factory)
reactor.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment