@@ -0,0 +1,906 @@
+from twisted.internet import endpoints, protocol, reactor%0Afrom twisted.protocols import basic%0Afrom twisted.web.client import getPage%0A%0Aimport time%0A%0Aclass ProxyProtocol(basic.LineReceiver):%0A    def lineReceived(self, line):%0A        if not line.startswith('http://'):%0A            return%0A%0A        start = time.time()%0A%0A        print 'Fetching %7B%7D'.format(line)%0A        def gotPage(data):%0A            print 'Fetched %7B%7D in %7B%7D sec'.format(line, time.time() - start)%0A            self.transport.write(data)%0A%0A        def errGettingPage(reason):%0A            print 'Error while fetching %7B%7D: %7B%7D'.format(line, reason.getErrorMessage())%0A%0A        d = getPage(line)%0A        d.addCallback(gotPage)%0A        d.addErrback(errGettingPage)%0A%0Aif __name__ == '__main__':%0A    factory = protocol.ServerFactory()%0A    factory.protocol = ProxyProtocol%0A    endpoints.serverFromString(reactor, 'tcp:8000').listen(factory)%0A%0A    reactor.run()%0A

Add simple proxy with closure style callbacks