Write all data of an NetworkReply
-
I tried to write the data of an network reply but the file was empty.Here's the code I used :
@QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
QVariant variant=reply->header(QNetworkRequest::LocationHeader);
QFile file("out.txt");
file.write(variant.typeName());@
I want to read all the data to see how is stored so I can continue writing my program. -
You didn't open file.
@
QFile file("out.txt");
file.open(QIODevice::WriteOnly);
file.write(variant.typeName());
@Also I guess you want to see content of header so you should use "rawHeader"::http://developer.qt.nokia.com/doc/qt-4.8/qnetworkreply.html#rawHeader
-
Thank you.Now I have another problem.After a post request I receive some html code,I saw this with the help of Chrome.How do I extract that code from the QNetworkReply?I know how to get the headers but not this.Thank you again.
-
QNetworkReply inherits "QIODevice":http://developer.qt.nokia.com/doc/qt-4.8/qiodevice.html so I think it is like reading from file.
-
readAll() gets you all the data received in the reply.
Also, if you connect to the finished() signal of the QNetworkAccessManager, that contains the reply in its argument, you don't need the call to sender() then.
-
I figured out.Thank you very much.
-
After monitoring http request with the help off google chrome I see that a http post request is made by a script.I see that it's initiator is game.js:17 (a javascript).Can I make a http request to that script or how can I do it?Is it necessary to use XMLHttpRequest?
-
Here is an image from Chrome
http://imageshack.us/photo/my-images/641/96160298.png
This post call modifies the source code of the page(is returning a form with a sid key that I need).Is there a way to do this call with QNetworkHttpRequest? -
You can always imitate what that script does and modify your own requests. Unfortunately there's nothing else to add here. Self modifying code usually tends to be tricky to analyze.