From 02d6a326e4996ae9408b97078f5a0cdd9f2d8090 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 18 May 2016 08:59:04 -0400 Subject: [PATCH] Make the input parsing a bit more flexible with regards to a newline on the end of the input JSON or not. --- src/server/RestStructs.cpp | 2 ++ src/server/WebSocket.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server/RestStructs.cpp b/src/server/RestStructs.cpp index a799728..0b89c4c 100644 --- a/src/server/RestStructs.cpp +++ b/src/server/RestStructs.cpp @@ -44,6 +44,7 @@ RestInputStruct::RestInputStruct(QString message, bool isRest){ //Now Parse out the Body into the JSON fields and/or arguments structure //NOTE: if the body of the message is encrypted, then it needs to be decrypted outside the struct first, // then run the "ParseBodyIntoJson()" function to read/convert the data as needed. + qDebug() << "Got request:" << message << isRest << Header << bridgeID; if(Header.isEmpty() || isRest){ //no other data processing needed ParseBodyIntoJson(); } @@ -52,6 +53,7 @@ RestInputStruct::RestInputStruct(QString message, bool isRest){ RestInputStruct::~RestInputStruct(){} void RestInputStruct::ParseBodyIntoJson(){ + if(Body.endsWith("\n")){ Body.chop(1); } if(Body.startsWith("{") && Body.endsWith("}") ){ QJsonDocument doc = QJsonDocument::fromJson(Body.toUtf8()); if(!doc.isNull() && doc.isObject() ){ diff --git a/src/server/WebSocket.cpp b/src/server/WebSocket.cpp index b318930..4ca3b66 100644 --- a/src/server/WebSocket.cpp +++ b/src/server/WebSocket.cpp @@ -175,7 +175,7 @@ void WebSocket::EvaluateREST(QString msg){ } void WebSocket::EvaluateRequest(const RestInputStruct &REQ){ - //qDebug() << "Evaluate Request:" << REQ.namesp << REQ.name << REQ.args; + qDebug() << "Evaluate Request:" << REQ.namesp << REQ.name << REQ.args; RestOutputStruct out; out.in_struct = REQ; QHostAddress host;