Simple proxy requiring another proxy with twisted

岁酱吖の 提交于 2019-12-12 02:27:47

问题


I came across this simple proxy example that uses Twisted:

# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

from twisted.internet import reactor
from twisted.web import proxy, server

site = server.Site(proxy.ReverseProxyResource('yahoo.com', 80, ''))
reactor.listenTCP(8080, site)
reactor.run()

The issue is that my computer needs to use a proxy itself to access the web, so I was wondering if there is a way to specify those proxy settings?


回答1:


Not really. At least, there's not an easy way to do it with Twisted.

ReverseProxyResource delegates to ReverseProxyRequest which does a direct TCP connection to the specified host (in this case, yahoo.com).

You could probably cobble something together by adapting ReverseProxyRequest to use twisted.web.client.ProxyAgent. Arguably, Twisted itself should provide a way to parametrize ReverseProxyResource by agent.



来源:https://stackoverflow.com/questions/9227937/simple-proxy-requiring-another-proxy-with-twisted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!