mirror of https://github.com/aria2/aria2
2009-05-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Refactored. * src/XmlRpcMethod.ccpull/1/head
parent
92b3f57ac9
commit
e332ef3e1c
|
@ -1,3 +1,8 @@
|
||||||
|
2009-05-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Refactored.
|
||||||
|
* src/XmlRpcMethod.cc
|
||||||
|
|
||||||
2009-05-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-05-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Added XmlRpcResponse class. XmlRpcMethod::execute() now returns
|
Added XmlRpcResponse class. XmlRpcMethod::execute() now returns
|
||||||
|
|
|
@ -100,33 +100,21 @@ static void encodeValue(const BDE& value, std::ostream& o)
|
||||||
o << "</value>";
|
o << "</value>";
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string encodeXml(const BDE& param)
|
|
||||||
{
|
|
||||||
std::stringstream o;
|
|
||||||
o << "<?xml version=\"1.0\"?>" << "<methodResponse>"
|
|
||||||
<< "<params>" << "<param>";
|
|
||||||
encodeValue(param, o);
|
|
||||||
o << "</param>" << "</params>" << "</methodResponse>";
|
|
||||||
return o.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string encodeErrorXml(const BDE& faultValue)
|
|
||||||
{
|
|
||||||
assert(faultValue.isDict());
|
|
||||||
std::stringstream o;
|
|
||||||
o << "<?xml version=\"1.0\"?>" << "<methodResponse>" << "<fault>";
|
|
||||||
encodeValue(faultValue, o);
|
|
||||||
o << "</fault>" << "</methodResponse>";
|
|
||||||
return o.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string XmlRpcResponse::toXml() const
|
std::string XmlRpcResponse::toXml() const
|
||||||
{
|
{
|
||||||
|
std::stringstream o;
|
||||||
|
o << "<?xml version=\"1.0\"?>" << "<methodResponse>";
|
||||||
if(_code == 0) {
|
if(_code == 0) {
|
||||||
return encodeXml(_param);
|
o << "<params>" << "<param>";
|
||||||
|
encodeValue(_param, o);
|
||||||
|
o << "</param>" << "</params>";
|
||||||
} else {
|
} else {
|
||||||
return encodeErrorXml(_param);
|
o << "<fault>";
|
||||||
|
encodeValue(_param, o);
|
||||||
|
o << "</fault>";
|
||||||
}
|
}
|
||||||
|
o << "</methodResponse>";
|
||||||
|
return o.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace xmlrpc
|
||||||
|
|
Loading…
Reference in New Issue