summaryrefslogtreecommitdiff
path: root/src/WebSocketSession.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/WebSocketSession.cc')
-rw-r--r--src/WebSocketSession.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/WebSocketSession.cc b/src/WebSocketSession.cc
index 86fb08d2..aced5622 100644
--- a/src/WebSocketSession.cc
+++ b/src/WebSocketSession.cc
@@ -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);