|
@@ -161,6 +161,7 @@ void onMsgRecvCallback(wslay_event_context_ptr wsctx,
|
|
|
// TODO Only process text frame
|
|
|
ssize_t error = 0;
|
|
|
auto json = wsSession->parseFinal(nullptr, 0, error);
|
|
|
+ auto preauthorized = RpcRequest::MUST_AUTHORIZE;
|
|
|
if(error < 0) {
|
|
|
A2_LOG_INFO("Failed to parse JSON-RPC request");
|
|
|
RpcResponse res
|
|
@@ -169,9 +170,10 @@ void onMsgRecvCallback(wslay_event_context_ptr wsctx,
|
|
|
return;
|
|
|
}
|
|
|
Dict* jsondict = downcast<Dict>(json);
|
|
|
+ auto e = wsSession->getDownloadEngine();
|
|
|
if(jsondict) {
|
|
|
- RpcResponse res = processJsonRpcRequest(jsondict,
|
|
|
- wsSession->getDownloadEngine());
|
|
|
+ RpcResponse res =
|
|
|
+ processJsonRpcRequest(jsondict, e, preauthorized);
|
|
|
addResponse(wsSession, res);
|
|
|
} else {
|
|
|
List* jsonlist = downcast<List>(json);
|
|
@@ -181,9 +183,12 @@ void onMsgRecvCallback(wslay_event_context_ptr wsctx,
|
|
|
for(List::ValueType::const_iterator i = jsonlist->begin(),
|
|
|
eoi = jsonlist->end(); i != eoi; ++i) {
|
|
|
Dict* jsondict = downcast<Dict>(*i);
|
|
|
- if(jsondict) {
|
|
|
- results.push_back(processJsonRpcRequest
|
|
|
- (jsondict, wsSession->getDownloadEngine()));
|
|
|
+ if (jsondict) {
|
|
|
+ auto resp = processJsonRpcRequest(jsondict, e, preauthorized);
|
|
|
+ if (resp.code == 0) {
|
|
|
+ preauthorized = RpcRequest::PREAUTHORIZED;
|
|
|
+ }
|
|
|
+ results.push_back(std::move(resp));
|
|
|
}
|
|
|
}
|
|
|
addResponse(wsSession, results);
|