This commit is contained in:
Kris Moore
2016-01-05 15:54:42 -05:00
2 changed files with 12 additions and 3 deletions

View File

@@ -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"){

View File

@@ -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";
}