Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to read data from QNetworkReply being used by QWebPage?
    primarykey
    data
    text
    <p>I use <a href="http://doc.qt.nokia.com/latest/qwebpage.html" rel="nofollow"><code>QWebPage</code></a> to download a webpage as well as all its resources. At the same time I'd like to get hold on raw data being downloaded by Qt during this process. Doing this by reading data from <a href="http://doc.qt.nokia.com/latest/qnetworkreply.html" rel="nofollow"><code>QNetworkReply</code></a> in <a href="http://doc.qt.nokia.com/latest/qnetworkaccessmanager.html#finished" rel="nofollow"><code>void QNetworkAccessManager::finished(QNetworkReply * reply)</code></a> signal is not a good solution as data could have been already read by <code>QWebPage</code> itself. This is because</p> <blockquote> <p>QNetworkReply is a sequential-access QIODevice, which means that once data is read from the object, it no longer kept by the device.</p> </blockquote> <p>according to <a href="http://doc.qt.nokia.com/latest/qnetworkreply.html#details" rel="nofollow">detailed description</a> of <code>QNetworkReply</code>.</p> <p>However <code>QWebPage</code> can be configured to use custom <a href="http://doc.qt.nokia.com/latest/qnetworkaccessmanager.html" rel="nofollow"><code>QNetworkAccessManager</code></a> with overriden <code>createRequest</code> method</p> <pre><code>QNetworkReply * QNetworkAccessManager::createRequest ( Operation op, const QNetworkRequest &amp; req, QIODevice * outgoingData = 0 ) </code></pre> <p>I think the right solution would be to create a proxy for <code>QNetworkReply</code> and return it in the <code>createRequest</code> method. This proxy should allow for reading data from reply as is the case with the original <code>QNetworkReply</code> (so that <code>QWebPage</code> could read data from it) but at the same time this proxy should allow for reading data by other objects after it have been read by <code>QWebPage</code>. In other words we need <a href="http://en.wikipedia.org/wiki/Tee_%28command%29" rel="nofollow">tee</a> for <code>QNetworkReply</code>'s <code>IODevice</code> base class.</p> <p>How to write this proxy?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload