mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Fix up some REST input parsing.
This commit is contained in:
@@ -39,15 +39,17 @@ public:
|
||||
if(message.isEmpty()){ return; }
|
||||
//Pull out any REST headers
|
||||
Body = message;
|
||||
qDebug() << "Raw Message:" << message;
|
||||
if(!message.startsWith("{")){
|
||||
Header = message.section("\n{",0,0).split("\n");
|
||||
Header = message.section("{",0,0).split("\n");
|
||||
Body = "{"+message.section("{",1, 1000000);
|
||||
}
|
||||
if(!Header.isEmpty()){
|
||||
QString line = Header.takeFirst(); //The first line is special (not a generic header)
|
||||
VERB = line.section(" ",0,0);
|
||||
URI = line.section(" ",1,1);
|
||||
HTTPVERSION = line.section(" ",2,2);
|
||||
Body = message.remove(Header.join("\n")+"\n"); //chop the headers off the front
|
||||
//Body = message.remove(Header.join("\n")+"\n"); //chop the headers off the front
|
||||
if(!Header.filter("Authorization:").isEmpty()){
|
||||
line = Header.filter("Authorization:").takeFirst().section("Authorization: ",1,50).simplified();
|
||||
if(line.section(" ",0,0).toLower()=="basic"){
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// =================================
|
||||
#include "WebSocket.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#define DEBUG 1
|
||||
#define IDLETIMEOUTMINS 30
|
||||
|
||||
@@ -304,7 +306,12 @@ void WebSocket::EvaluateTcpMessage(){
|
||||
//Need to read the data from the Tcp socket and turn it into a string
|
||||
qDebug() << "New TCP Message:";
|
||||
if(idletimer->isActive()){ idletimer->stop(); }
|
||||
EvaluateREST( QString(TSOCKET->readAll()) );
|
||||
QString msg = QString(TSOCKET->readAll());
|
||||
for(int i=0; i<5 && !msg.endsWith("}"); i++){
|
||||
usleep(10000); //10ms
|
||||
msg.append( QString(TSOCKET->readAll()) );
|
||||
}
|
||||
EvaluateREST(msg );
|
||||
idletimer->start();
|
||||
qDebug() << " - Done with TCP Message";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user