[Twisted-Python] XMLRPC getting calling host
Hey there! Just a little try to check whether I'm still subscribed to twisted, as today's other posts regarding the safe pickling never got through, somehow... I've come to the point where I need to query the IP an XMLRPC request came from. In UDP, you get it served when the call to datagramReceived comes through, but I've not seen any attribute of the XMLRPC class, or of the underlying Resource class which states anything about how to get this attribute. Is it possible? And if, how? Thanks! Heiko.
Heiko Wundram wrote:
I've come to the point where I need to query the IP an XMLRPC request came from. In UDP, you get it served when the call to datagramReceived comes through, but I've not seen any attribute of the XMLRPC class, or of the underlying Resource class which states anything about how to get this attribute. Is it possible? And if, how?
Just a stab in the dark here, but I believe it's possible to override the render method to get this information via the request parameter. Something like: from twisted.web import xmlrpc class MyXmlRpcHandler(xmlrpc.XMLRPC): def render(self, request): self._ip = request.something # Get IP information here xmlrpc.XMLRPC.render(self, request) def xmlrpc_method(self, *args): # You can now use self._ip for this instance of MyXmlRpcHandler Sorry for my lack of knowledge in the request object object, but every known html info about the request is available there.
On Wed, May 28, 2003 at 06:22:16AM +0200, Heiko Wundram wrote:
I've come to the point where I need to query the IP an XMLRPC request came from. In UDP, you get it served when the call to datagramReceived comes through, but I've not seen any attribute of the XMLRPC class, or of the underlying Resource class which states anything about how to get this attribute. Is it possible? And if, how?
Request objects have a .getClientIP method. -Andrew.
participants (3)
-
Andrew Bennetts
-
Heiko Wundram
-
Wari Wahab