QNetworkAccessManager doesn’t download whole web page
Hi. I’m trying to donwload page via http using QNetworkAccessManager
I store data in QByteArray and append readAll() from respective QNetworkReply object on each call of readyRead signal
but when I check QByteArray content on finished signal of QNetworkAccessManager, it contains not whole page, it is cut in a certain place.
I see there is a kind of limitation, but I can’t find the way to avoid it
8 replies
Did you really read the last chunk?
finished() is emitted as soon as the request is done from a protocol perspective. You may have pending data in the reply that you have not read yet. It’s good practice to call readAll() in your slot connected to finished() a last time to get the last chunk of data.
If your data is not big or you do not need the data chunkwise as soon as possible, you can have QNetworkReply collect the data and read the whole page after finished() with readAll(). See QNetworkReply::finished() [doc.qt.nokia.com] for some details.
The finished signal of QNetworkReply is connected to a private slot of QNetworkAccessManager which in turn immediately emits finished(QNetworkReply*). So, no, there is no significant difference.
As things work for most of the other people, it would be handy, if you could provide us a small, complete, compilable and running example that demonstrates the error and that we can run on our boxes.
Well thr code is as following
- void bot::recieveId() // this function initiates request
- {
- manager->get(QNetworkRequest(QUrl("http://qt.nokia.com")));//it's not actual URL, but problem is the same
- }
- {
- rawData=_reply->readAll();
- qDebug()<<rawData;
- }
manager and rawData are QNetworkAccessManager (instantiated in counstructor) and QByteArray (static)
the last thing I have in console is
- <li><a href="http://qt.nokia.com/developer/eclipse-integration">Eclipse plug-in</a></li>
while there is a hundred or more strings after
Hi volker,
I am using QNAM to download a XML file from server but getting “connection timed out” error message in reply. In your previous post you were asking whether Kxyu is using proxy in his program. My program is behind a corporate proxy, can it cause this issue? If yes, could you please let me know how to resolve the problem?
Note: Through browser I can access the page successuflly
You must log in to post a reply. Not a member yet? Register here!


