我使用python中的xmlrpclib连接到验证csrf令牌的xmlrpc服务器。在
proxy = ServerProxy("http://127.0.0.1:9091/transmission/rpc/")
proxy.system.listMethods()
我得到了以下例外
^{pr2}$当尝试从浏览器访问同一个xmlrpc服务器时,我收到以下错误消息。在
Your request had an invalid session-id header.
To fix this, follow these steps:
- When reading a response, get its X-Transmission-Session-Id header and remember it
- Add the updated header to your outgoing requests
- When you get this 409 error message, resend your request with the updated header
This requirement has been added to help prevent CSRF attacks.
X-Transmission-Session-Id: lhfIlFPd1W6pctlHSiS3BuNXdFr0al1qxfM4wSLvVkdh5wOu
现在,我正在寻找一种方法,每当我使用ServerProxy对象调用远程过程时,都可以将这个会话id发送到服务器。有可能吗?在
首先,传输不公开XML-RPC服务。它是一个JSON-RPC服务。使用xmlrpclib根本不起作用。在
你需要完全按照错误信息所说的去做。。。每当收到409错误时,从响应头记录X-Transmission-Session-Id,然后在请求头中添加X-Transmission-Session-Id重新发送请求。实现这一点的一种方法是使用httplib。在
传输的RPC服务要求请求正文中包含有效的JSON。您可以在这里找到规范:https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt
相关问题 更多 >
编程相关推荐