PDA

View Full Version : Reply Header - Content-Type



seink
16th December 2010, 12:51
Hello! This noob here has a problem and needs help ^^
My task is:
-Map the requests made by a browser created with QT(Arora);
-Group the requests by their reply`s header`s content-type;

while looking through the source I found the class NetworkAccessManager, child of QNetworkAccessManager, that I supose it manages all network connections.
In the method createRequest I used a qdebug to see all the headers of my request`s reply, but the problem is.....I can`t see many of them, even ones that I`m sure it has header(I looked with other tools), their header does not appear....

Finally, my questions are:
1)How can I get the type of the file I`m receiving on each request I make?
2)Is there something that clears the header of the reply internally inside the qtweb?
3)Is there another way to make this code work? XD

I used the following code to try to see the headers


QList<QByteArray> l = reply->rawHeaderList();
int sz = l.count();
qDebug() << sz;
for(int i = 0;i<sz;i++){
qDebug()<<r->rawHeaderList()[i];
}

Here is the function code


QNetworkReply *NetworkAccessManager::createRequest(QNetworkAcces sManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
{
if (op == PostOperation && outgoingData) {
QByteArray outgoingDataByteArray = outgoingData->peek(1024 * 1024);
BrowserApplication::autoFillManager()->post(request, outgoingDataByteArray);
}

QNetworkReply *reply = 0;
// Check if there is a valid handler registered for the requested URL scheme
if (m_schemeHandlers.contains(request.url().scheme()) )
reply = m_schemeHandlers[request.url().scheme()]->createRequest(op, request, outgoingData);
if (reply){
return reply;
}

QNetworkRequest req = request;
#if QT_VERSION >= 0x040600
req.setAttribute(QNetworkRequest::HttpPipeliningAl lowedAttribute, true);
#endif
if (!m_acceptLanguage.isEmpty())
req.setRawHeader("Accept-Language", m_acceptLanguage);

// Adblock
if (op == QNetworkAccessManager::GetOperation) {
if (!m_adblockNetwork)
m_adblockNetwork = AdBlockManager::instance()->network();
reply = m_adblockNetwork->block(req);
if (reply){
return reply;
}
}

reply = QNetworkAccessManager::createRequest(op, req, outgoingData);
emit requestCreated(op, req, reply);
return reply;
}

wysota
16th December 2010, 13:31
At the time createRequest() is called there is no reply yet hence no headers for it. Connect to the finished() signal instead.

seink
16th December 2010, 17:11
thanks!
I didn`t expect a reply so fast! XD
I tested it and now its working!
no more questions for now...