I use QWebPageto load a web page, as well as all its resources. At the same time, I would like to get the raw data loaded by Qt during this process. Performing this by reading the data QNetworkReplyinto the void QNetworkAccessManager::finished(QNetworkReply * reply)
signal is not a good solution, since the data could already be read by ourselves QWebPage. It's because
QNetworkReply is a QIODevice sequential access, which means that as soon as data is read from the object, it is no longer stored on the device.
according to the detailed description QNetworkReply .
However, QWebPageyou can configure to use custom QNetworkAccessManagerusing the override methodcreateRequest
QNetworkReply * QNetworkAccessManager::createRequest ( Operation op, const QNetworkRequest & req, QIODevice * outgoingData = 0 )
I think the correct solution would be to create a proxy for QNetworkReplyand return it to the method createRequest. This proxy should allow reading data from the response, as in the case of the original one QNetworkReply(so that it QWebPagecan read data from it), but at the same time, this proxy should allow reading data from other objects after it has been read QWebPage. In other words, we need tee for the base class QNetworkReply IODevice.
How to record this proxy?
source
share