mirror of
https://github.com/aria2/aria2.git
synced 2025-04-07 06:27:37 +03:00
2009-12-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added system.multicall XML-RPC method. * src/XmlRpcMethod.cc * src/XmlRpcMethod.h * src/XmlRpcMethodFactory.cc * src/XmlRpcMethodImpl.cc * src/XmlRpcMethodImpl.h * test/XmlRpcMethodTest.cc
This commit is contained in:
parent
838fcbbecd
commit
af20aea88c
7 changed files with 135 additions and 1 deletions
|
@ -59,6 +59,8 @@
|
|||
#include "message.h"
|
||||
#include "FeatureConfig.h"
|
||||
#include "array_fun.h"
|
||||
#include "XmlRpcMethodFactory.h"
|
||||
#include "XmlRpcResponse.h"
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
# include "bittorrent_helper.h"
|
||||
# include "BtRegistry.h"
|
||||
|
@ -111,6 +113,8 @@ const std::string KEY_LENGTH = "length";
|
|||
const std::string KEY_URI = "uri";
|
||||
const std::string KEY_VERSION = "version";
|
||||
const std::string KEY_ENABLED_FEATURES = "enabledFeatures";
|
||||
const std::string KEY_METHOD_NAME = "methodName";
|
||||
const std::string KEY_PARAMS = "params";
|
||||
}
|
||||
|
||||
static BDE createGIDResponse(int32_t gid)
|
||||
|
@ -815,6 +819,50 @@ BDE ChangePositionXmlRpcMethod::process
|
|||
return result;
|
||||
}
|
||||
|
||||
BDE SystemMulticallXmlRpcMethod::process
|
||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||
{
|
||||
const BDE& params = req._params;
|
||||
assert(params.isList());
|
||||
|
||||
if(params.size() != 1) {
|
||||
throw DL_ABORT_EX("Illegal argument. One item list is expected.");
|
||||
}
|
||||
const BDE& methodSpecs = params[0];
|
||||
BDE list = BDE::list();
|
||||
for(BDE::List::const_iterator i = methodSpecs.listBegin();
|
||||
i != methodSpecs.listEnd(); ++i) {
|
||||
if(!(*i).isDict()) {
|
||||
list << createErrorResponse
|
||||
(DL_ABORT_EX("system.multicall expected struct."));
|
||||
continue;
|
||||
}
|
||||
if(!(*i).containsKey(KEY_METHOD_NAME) ||
|
||||
!(*i).containsKey(KEY_PARAMS)) {
|
||||
list << createErrorResponse
|
||||
(DL_ABORT_EX("Missing methodName or params."));
|
||||
continue;
|
||||
}
|
||||
const std::string& methodName = (*i)[KEY_METHOD_NAME].s();
|
||||
if(methodName == "system.multicall") {
|
||||
list << createErrorResponse
|
||||
(DL_ABORT_EX("Recursive system.multicall forbidden."));
|
||||
continue;
|
||||
}
|
||||
SharedHandle<XmlRpcMethod> method = XmlRpcMethodFactory::create(methodName);
|
||||
XmlRpcRequest innerReq(methodName, (*i)[KEY_PARAMS]);
|
||||
XmlRpcResponse res = method->execute(innerReq, e);
|
||||
if(res._code == 0) {
|
||||
BDE l = BDE::list();
|
||||
l << res._param;
|
||||
list << l;
|
||||
} else {
|
||||
list << res._param;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
BDE NoSuchMethodXmlRpcMethod::process
|
||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue