PDA

View Full Version : Asynchronous loading from HTTP (as data stream)



shestero
21st October 2012, 10:45
I fail to find any example or hint how too organize raw data streaming loading from HTTP. This means that you are able to access to already received data before the transfer is completed. The found samples of asynchronous call through QNetworkAccessManager give ability to do some other tasks asynchronously, but all they waiting for signal “finished” and then read all bunch of data from QnetworkReply using readAll method.

This general question comes from my more practical task to quickly get some data from a huge XML using SAX (not storing all XML in memory). I tried to do it that way:


// get and parse XML:
QXmlSimpleReader reader;
reader.setContentHandler(this);
reader.setErrorHandler(this);
QIODevice* src = (QIODevice*) m_manager.get( QNetworkRequest(url) );
QXmlInputSource xmlsource(src);
reader.parse(&xmlsource, true);But after startDocument() in my handler was called it then called error handled with fatal error – unexpected end of document.