Using QHttp in a QDS service
Hi all,
In a standalone application, I can successfully use QHttp to communicate with a backend server.
Now I'm trying to publish this communication as a QDS service. Basically, the same code (signal connecting, same slots etc) was transfered to the server.
The service uses a utility class that executes this QHttp object successfully and retrieves the information I want, though it generates two requestFinished signals.
The first is right after http->request() and returns a "" string
The second takes a bit longer (as expected) and returns the desired information.
I have tried placing the following after http->request():
Code:
while (!reponseRetrieved) {
loop.
processEvents(QEventLoop::AllEvents);
// with other parameter variations}
But the signal is still executing twice. I'm trying to synchronize the http so the service returns the information correctly.
Any reason for this behavior?
Re: Using QHttp in a QDS service
First requestFinished signal is probably the result of QHttp::setHost and in that case is perfectly normal. You need to use the request id to look for requests you're monitoring.
Re: Using QHttp in a QDS service
Hum, that would explain only one done signal, though the actual response should really have requestID = 2 (for the first service call)?
If that's the normal behavior than ok by me. I'm just curious why wouldn't the setHost count as a request itself when running the same code in a standalone application?
Re: Using QHttp in a QDS service
Maybe the signal was firing before you made the signal/slot connection? Hard to guess without seeing the actual code. I'm sure the behaviour is coherent on all platforms.
Re: Using QHttp in a QDS service
Hum, probably. But since the actual purpose is to be in a service, and checking with stateChanged confirmed that only one request is actually sent to the backend server, I'm cool with that.
Will improve request ID management. Thanks for the info.