From 68eb1b6737bf10d00360cab9b85c1ee090acd272 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 17 May 2012 22:52:39 +0900 Subject: [PATCH] Ignore unacceptable options in RPC request instead of throwing error. This change allows RPC client to send same options for the different type of downloads. --- src/RpcMethod.cc | 4 ++-- test/RpcMethodTest.cc | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/RpcMethod.cc b/src/RpcMethod.cc index 9cacf072..46dba121 100644 --- a/src/RpcMethod.cc +++ b/src/RpcMethod.cc @@ -96,8 +96,8 @@ void gatherOption } const SharedHandle& handler = optionParser->find(pref); if(!handler || !pred(handler)) { - throw DL_ABORT_EX - (fmt("%s option cannot be used in this context.", optionName.c_str())); + // Just ignore the unacceptable options in this context. + continue; } const String* opval = downcast((*first).second); if(opval) { diff --git a/test/RpcMethodTest.cc b/test/RpcMethodTest.cc index 121357aa..549329b5 100644 --- a/test/RpcMethodTest.cc +++ b/test/RpcMethodTest.cc @@ -507,7 +507,8 @@ void RpcMethodTest::testChangeOption_withNotAllowedOption() opt->put(PREF_MAX_OVERALL_DOWNLOAD_LIMIT->k, "100K"); req.params->append(opt); RpcResponse res = m.execute(req, e_.get()); - CPPUNIT_ASSERT_EQUAL(1, res.code); + // The unacceptable options are just ignored. + CPPUNIT_ASSERT_EQUAL(0, res.code); } void RpcMethodTest::testChangeOption_withoutGid() @@ -567,7 +568,8 @@ void RpcMethodTest::testChangeGlobalOption_withNotAllowedOption() opt->put(PREF_ENABLE_RPC->k, "100K"); req.params->append(opt); RpcResponse res = m.execute(req, e_.get()); - CPPUNIT_ASSERT_EQUAL(1, res.code); + // The unacceptable options are just ignored. + CPPUNIT_ASSERT_EQUAL(0, res.code); } void RpcMethodTest::testNoSuchMethod()