xmlrpc: send request as POST by default and use dont_filter

--HG--
extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40958
This commit is contained in:
Daniel Grana 2009-03-03 05:37:41 +00:00
parent ff7c6d3782
commit 309bf9277e
2 changed files with 9 additions and 0 deletions

View File

@ -15,6 +15,13 @@ class XmlRpcRequest(Request):
def __init__(self, *args, **kwargs):
params = kwargs.pop('params')
methodname = kwargs.pop('methodname')
# spec defines that requests must use POST method
kwargs.setdefault('method', 'POST')
# xmlrpc query multiples times over the same url
kwargs.setdefault('dont_filter', True)
Request.__init__(self, *args, **kwargs)
self.body = xmlrpclib.dumps(params, methodname)
self.headers.setdefault('Content-Type', 'text/xml')

View File

@ -189,6 +189,8 @@ class XmlRpcRequestTest(unittest.TestCase):
r = XmlRpcRequest('http://scrapytest.org/rpc2', methodname='login', params=('username', 'password'))
self.assertEqual(r.headers['Content-Type'], 'text/xml')
self.assertEqual(r.body, "<?xml version='1.0'?>\n<methodCall>\n<methodName>login</methodName>\n<params>\n<param>\n<value><string>username</string></value>\n</param>\n<param>\n<value><string>password</string></value>\n</param>\n</params>\n</methodCall>\n")
self.assertEqual(r.method, 'POST')
self.assertTrue(r.dont_filter, True)
if __name__ == "__main__":