How to use QNetworkAccessManager post
-
When I start debugging the value of url is: @synchronous data unavailable@ after the execution of this statement @reply =qnam.post(QNetworkRequest (url) m_pData);@
m_pData has good values
-NB-: I'm using https
-
So, you meant that the other qDebug gets displayed?
I'm not exactly sure, but I seem to vaguely remember, that after you do readAll(), QNR is flushed, so you can't really use it again. But I can't find any info on that in Qt 4.7 documentation, so my memory might be wrong here. Try storing the reply and doing the 'if' on the stored data.
-
[quote author="SamFaye" date="1314711148"]I do this @QUrl url; url.setUrl(valUrl);@
[/quote]That method has exactly the same problem as the constructor. Please use one of the static methods like QUrl::fromEncoded().
-
I have this error message when i use https and post @SSL: "Le nom d'hôte ne correspondait à aucun des hôtes valides pour ce certificat, Le certificat n'est pas sécurisé car auto-signé" @
After this message my application crache
My URL is like this: @https://Ip_machine/xxxxxxx@
What is missing??
-
You will have to handle SSL errors. See for example "this thread":http://developer.qt.nokia.com/forums/viewthread/5861/#35121.
bq. Note that calling ["ignoreSslErrors()":http://doc.qt.nokia.com/latest/qnetworkreply.html#ignoreSslErrors] without restraint may pose a security risk for your application. Use it with care.
-
I had done what Lukas Geyer said, now I didn't have the message but the application belong crashing
-
Where does it crash? Start the application in debug mode. The debugger will halt exactly where the application crashes.
-
This is because the other instructions are executed while the server response is not received. How to wait for the server response to continue execution of other instructions?
-
For example, you can use:
@
forever {
if (replyReceived) {
processReply();
break;
}
else
qApp->processEvents();
}
@
This will not block your app. Substitute if condition and processing with your own. -
[quote author="SamFaye" date="1314899811"]This is because the other instructions are executed while the server response is not received. How to wait for the server response to continue execution of other instructions?[/quote]
Which other instructions? QNAM emits the finished signal when the response is available. This is where your response handling code has to go.
Blocking your application until data is available is usually not the solution, it just covers a severe design flaw.