mirror of
https://github.com/aria2/aria2.git
synced 2026-04-03 03:09:04 +00:00
Allow missing params in XML-RPC request.
Now following request is legal: <methodCall> <methodName>aria2.getVersion</methodName> </methodCall>
This commit is contained in:
@@ -50,11 +50,13 @@ RpcRequest xmlParseMemory(const char* xml, size_t size)
|
||||
if(!XmlParser(&psm).parseMemory(xml, size)) {
|
||||
throw DL_ABORT_EX(MSG_CANNOT_PARSE_XML_RPC_REQUEST);
|
||||
}
|
||||
if(!downcast<List>(psm.getCurrentFrameValue())) {
|
||||
throw DL_ABORT_EX("Bad XML-RPC parameter list");
|
||||
SharedHandle<List> params;
|
||||
if(downcast<List>(psm.getCurrentFrameValue())) {
|
||||
params = static_pointer_cast<List>(psm.getCurrentFrameValue());
|
||||
} else {
|
||||
params = List::g();
|
||||
}
|
||||
return RpcRequest(psm.getMethodName(),
|
||||
static_pointer_cast<List>(psm.getCurrentFrameValue()));
|
||||
return RpcRequest(psm.getMethodName(), params);
|
||||
}
|
||||
#endif // ENABLE_XML_RPC
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
#ifdef ENABLE_XML_RPC
|
||||
void testParseMemory();
|
||||
void testParseMemory_shouldFail();
|
||||
void testParseMemory_withoutParams();
|
||||
void testParseMemory_withoutStringTag();
|
||||
#endif // ENABLE_XML_RPC
|
||||
};
|
||||
@@ -105,6 +106,10 @@ void RpcHelperTest::testParseMemory_shouldFail()
|
||||
} catch(RecoverableException& e) {
|
||||
// success
|
||||
}
|
||||
}
|
||||
|
||||
void RpcHelperTest::testParseMemory_withoutParams()
|
||||
{
|
||||
{
|
||||
std::string s =
|
||||
"<methodCall>"
|
||||
@@ -115,15 +120,13 @@ void RpcHelperTest::testParseMemory_shouldFail()
|
||||
RpcRequest req = xmlParseMemory(s.c_str(), s.size());
|
||||
CPPUNIT_ASSERT(req.params);
|
||||
}
|
||||
try {
|
||||
{
|
||||
std::string s =
|
||||
"<methodCall>"
|
||||
" <methodName>aria2.addURI</methodName>"
|
||||
"</methodCall>";
|
||||
xmlParseMemory(s.c_str(), s.size());
|
||||
CPPUNIT_FAIL("exception must be thrown.");
|
||||
} catch(RecoverableException& e) {
|
||||
// success
|
||||
RpcRequest req = xmlParseMemory(s.c_str(), s.size());
|
||||
CPPUNIT_ASSERT(req.params->size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user