1
我該如何處理這段代碼才能發送2個不同的請求。該請求是按以下順序:蟒蛇扭曲代理髮送2個請求
Request1:
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()
扭曲的代理將連接到任何幫助表示讚賞另一個外部代理 ..
這是來自wireshark的圖片,顯示了我試圖實現的內容![請求] [1] [1] http://imgur.com/AR3hYPj @bennomadic – mikie