Thank you for your answer. I am not sure that I agree with it relative to my implementation. May be you can take a look at it (code below)
class RemoteManagers : public QObject
{
Q_OBJECT
private:
QHttp m_http;
private slots:
void OnrequestFinished ( int id, bool error );
public:
void GetManagers();
};
class CMainView : public QMainWindow
{
Q_OBJECT
private:
RemoteManagers m_remotemanagers;
private slots:
void OnGetManagers();
void OnManagersReceived (QStringList lst);
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
CMainView w;
w.show();
return a.exec();
}
void CMainView::OnGetManagers()
{
m_remotemanagers.GetManagers();
}
void RemoteManagers::GetManagers()
{
QHttpRequestHeader* myheader = new QHttpRequestHeader("POST", "/MyWebsite/GetManagers.asmx");
QHttpRequestHeader& header = *myheader;
header.setValue("Host", "http://localhost:1048");
header.setValue("charset", "utf-8");
header.setContentType("application/x-www-form-urlencoded");
header.setContentLength(13);
header.setValue("Connection", "Keep-Alive");
header.setValue("Referer", "Referer=http://localhost:1048/MyWebsite/GetManagers.asmx?op=Portfolios");
m_http.setHost("http://localhost:1048");
m_http.request(header, "UserName=test");
connect((QObject*)(&m_http), SIGNAL(requestFinished ( int id, bool error )), this, SLOTOnrequestFinished( int id, bool error )));
}
So, I think that I am already handling the event loop correctly because of the following:
1. This is a GUI application, so there is an event loop.
2. Class, that handles http POST request is a RemoteManagers class that is instantiated in CMainView class.
3. I copied values for header settings from the actual request to the webservice that I capture in the debug mode for webservice when request comes from the browser.
m_http.request does not even reach the Web Server (I am running it in the debug mode, and when I access the service via the browser I am hitting a breakpoint...).
Any input is greatly appreciated
Bookmarks