From d7c7c961e8c35c2d8587ec7f60aac5e309284a97 Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 13 Nov 2009 11:00:08 +0000 Subject: Added SessionIDs to http communication. Made SAXParser run on const char*. --- client/netcom.cc | 32 +++++++++++++++++++++++++++++--- client/netcom.h | 1 + 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/netcom.cc b/client/netcom.cc index be240e2..4126b02 100644 --- a/client/netcom.cc +++ b/client/netcom.cc @@ -62,12 +62,34 @@ NetCom::NetCom(QString host, quint16 port, QString user, QString cpr) #else http.setHost(host, QHttp::ConnectionModeHttp, port); #endif - + transfering = false; + + QHttpRequestHeader h("HTTP 1.1", "/"); + http.request(h, ""); + + transfering = true; + buffer = ""; + do { + qApp->processEvents(QEventLoop::WaitForMoreEvents); + } while(transfering); + + sessionid = http.lastResponse().value("SessionID"); + printf("SESSION ID: %s\n", sessionid.toStdString().c_str()); } NetCom::~NetCom() { + QHttpRequestHeader h("HTTP 1.1", "/"); + h.setValue("SessionCommit", ""); + h.setValue("SessionID", sessionid); + http.request(h, ""); + + transfering = true; + buffer = ""; + do { + qApp->processEvents(QEventLoop::WaitForMoreEvents); + } while(transfering); } QDomDocument NetCom::send(QString templ, QString macro, bool lockgui) @@ -93,7 +115,9 @@ QDomDocument NetCom::send(QString templ, QString macro, bool lockgui) printf("\nSending request:\n%s", doc.toString().toStdString().c_str()); - http.post("/", doc.toByteArray()); + QHttpRequestHeader h("HTTP 1.1", "/"); + h.setValue("SessionID", sessionid); + http.request(h, doc.toByteArray()); QDomDocument res_doc; transfering = true; @@ -151,7 +175,9 @@ void NetCom::send(QVector< Widget* > widgets, QString templ, QString macro, QStr printf("\nSending commit:\n%s", doc.toString().toStdString().c_str()); - http.post("/", doc.toByteArray()); + QHttpRequestHeader h("HTTP 1.1", "/"); + h.setValue("SessionID", sessionid); + http.request(h, doc.toByteArray()); transfering = true; buffer = ""; diff --git a/client/netcom.h b/client/netcom.h index f1a8766..718d5a6 100644 --- a/client/netcom.h +++ b/client/netcom.h @@ -64,6 +64,7 @@ private: QHttp http; QByteArray buffer; + QString sessionid; }; #endif/*__PRACRO_NETCOM_H__*/ -- cgit v1.2.3