【发布时间】:2014-01-30 19:16:54
【问题描述】:
如何处理此代码才能发送 2 个单独的请求。请求将按以下顺序排列:
请求1:
HEAD http://google.com
Host: google.com
...等待谷歌服务器的回复...
请求2:
GET http://yahoo.com HTTP/1.1
User-Agent: mozilla
Accept: */*
...从浏览器发送的第二个请求,而第一个请求对于所有请求都是静态的...
我要修改的代码是:
from twisted.web import proxy, http
class SnifferProxy(proxy.Proxy):
def allContentReceived(self):
print "Received data..."
print "method = %s" % self._command
print "action = %s" % self._path
print "ended content manipulation\n\n"
return proxy.Proxy.allContentReceived(self)
class ProxyFactory(http.HTTPFactory):
protocol = SnifferProxy
if __name__ == "__main__":
from twisted.internet import reactor
reactor.listenTCP(8080, ProxyFactory())
reactor.run()
扭曲的代理将连接到另一个外部代理 任何帮助表示赞赏..
【问题讨论】: