Add PUT REST support, and clean up the bytes calculation for the output JSON data.

This commit is contained in:
Ken Moore
2016-01-05 16:20:37 -05:00
parent 18adf6d486
commit 7ffec5003b
2 changed files with 3 additions and 2 deletions

View File

@@ -139,7 +139,8 @@ public:
headers << "Date: "+QDateTime::currentDateTime().toString(Qt::ISODate);
if(!Header.isEmpty()){ headers << Header; }
//Now add the body of the return
if(!Body.isEmpty()){ headers << "Content-Length: "+QString::number(Body.length()); }
qDebug() << "Return JSON:" << Body;
if(!Body.isEmpty()){ headers << "Content-Length: "+QString::number(Body.toUtf8().size()); } //number of bytes for the body
headers << Body;
return headers.join("\n");

View File

@@ -117,7 +117,7 @@ void WebSocket::EvaluateREST(QString msg){
void WebSocket::EvaluateRequest(const RestInputStruct &REQ){
RestOutputStruct out;
out.in_struct = REQ;
if(!REQ.VERB.isEmpty() && REQ.VERB != "GET" && REQ.VERB!="POST"){
if(!REQ.VERB.isEmpty() && REQ.VERB != "GET" && REQ.VERB!="POST" && REQ.VERB!="PUT"){
//Non-supported request (at the moment) - return an error message
out.CODE = RestOutputStruct::BADREQUEST;
}else if(out.in_struct.name.isEmpty() || out.in_struct.namesp.isEmpty() ){