summaryrefslogtreecommitdiff
path: root/src/HttpServerBodyCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-07-11 21:09:51 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-07-11 21:09:51 +0900
commit7c06b903f3493db95fcf4bd42cccc59e3b4d0692 (patch)
treef10a85795bb086e0b257a0e6c6c5ffb05f28f344 /src/HttpServerBodyCommand.cc
parent7a57ecc5f814dc305e5e4b9bd960d69b43870c0e (diff)
Use std::unique_ptr for ValueBase object hierarchy
Diffstat (limited to 'src/HttpServerBodyCommand.cc')
-rw-r--r--src/HttpServerBodyCommand.cc17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/HttpServerBodyCommand.cc b/src/HttpServerBodyCommand.cc
index 13e327be..67d660db 100644
--- a/src/HttpServerBodyCommand.cc
+++ b/src/HttpServerBodyCommand.cc
@@ -226,10 +226,9 @@ bool HttpServerBodyCommand::execute()
addHttpServerResponseCommand();
return true;
}
- std::shared_ptr<rpc::RpcMethod> method =
- rpc::RpcMethodFactory::create(req.methodName);
+ auto method = rpc::RpcMethodFactory::create(req.methodName);
A2_LOG_INFO(fmt("Executing RPC method %s", req.methodName.c_str()));
- rpc::RpcResponse res = method->execute(req, e_);
+ rpc::RpcResponse res = method->execute(std::move(req), e_);
bool gzip = httpServer_->supportsGZip();
std::string responseData = rpc::toXml(res, gzip);
httpServer_->feedResponse(std::move(responseData), "text/xml");
@@ -243,7 +242,7 @@ bool HttpServerBodyCommand::execute()
case RPC_TYPE_JSON:
case RPC_TYPE_JSONP: {
std::string callback;
- std::shared_ptr<ValueBase> json;
+ std::unique_ptr<ValueBase> json;
ssize_t error = 0;
if(httpServer_->getRequestType() == RPC_TYPE_JSONP) {
json::JsonGetParam param = json::decodeGetParams(query);
@@ -272,22 +271,20 @@ bool HttpServerBodyCommand::execute()
sendJsonRpcResponse(res, callback);
return true;
}
- const Dict* jsondict = downcast<Dict>(json);
+ Dict* jsondict = downcast<Dict>(json);
if(jsondict) {
rpc::RpcResponse res = rpc::processJsonRpcRequest(jsondict, e_);
sendJsonRpcResponse(res, callback);
} else {
- const List* jsonlist = downcast<List>(json);
+ List* jsonlist = downcast<List>(json);
if(jsonlist) {
// This is batch call
std::vector<rpc::RpcResponse> results;
for(List::ValueType::const_iterator i = jsonlist->begin(),
eoi = jsonlist->end(); i != eoi; ++i) {
- const Dict* jsondict = downcast<Dict>(*i);
+ Dict* jsondict = downcast<Dict>(*i);
if(jsondict) {
- rpc::RpcResponse r =
- rpc::processJsonRpcRequest(jsondict, e_);
- results.push_back(r);
+ results.push_back(rpc::processJsonRpcRequest(jsondict, e_));
}
}
sendJsonRpcBatchResponse(results, callback);