Results 1 to 3 of 3

Thread: Reply Header - Content-Type

  1. #1

    Default Reply Header - Content-Type

    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
    Qt Code:
    1. QList<QByteArray> l = reply->rawHeaderList();
    2. int sz = l.count();
    3. qDebug() << sz;
    4. for(int i = 0;i<sz;i++){
    5. qDebug()<<r->rawHeaderList()[i];
    6. }
    To copy to clipboard, switch view to plain text mode 
    Here is the function code
    Qt Code:
    1. QNetworkReply *NetworkAccessManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
    2. {
    3. if (op == PostOperation && outgoingData) {
    4. QByteArray outgoingDataByteArray = outgoingData->peek(1024 * 1024);
    5. BrowserApplication::autoFillManager()->post(request, outgoingDataByteArray);
    6. }
    7.  
    8. QNetworkReply *reply = 0;
    9. // Check if there is a valid handler registered for the requested URL scheme
    10. if (m_schemeHandlers.contains(request.url().scheme()))
    11. reply = m_schemeHandlers[request.url().scheme()]->createRequest(op, request, outgoingData);
    12. if (reply){
    13. return reply;
    14. }
    15.  
    16. QNetworkRequest req = request;
    17. #if QT_VERSION >= 0x040600
    18. req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
    19. #endif
    20. if (!m_acceptLanguage.isEmpty())
    21. req.setRawHeader("Accept-Language", m_acceptLanguage);
    22.  
    23. // Adblock
    24. if (op == QNetworkAccessManager::GetOperation) {
    25. if (!m_adblockNetwork)
    26. m_adblockNetwork = AdBlockManager::instance()->network();
    27. reply = m_adblockNetwork->block(req);
    28. if (reply){
    29. return reply;
    30. }
    31. }
    32.  
    33. reply = QNetworkAccessManager::createRequest(op, req, outgoingData);
    34. emit requestCreated(op, req, reply);
    35. return reply;
    36. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Reply Header - Content-Type

    At the time createRequest() is called there is no reply yet hence no headers for it. Connect to the finished() signal instead.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3

    Default Re: Reply Header - Content-Type

    thanks!
    I didn`t expect a reply so fast! XD
    I tested it and now its working!
    no more questions for now...

Similar Threads

  1. Retriving structure in qt-urgent.please reply.
    By savaliya_ambani in forum Qt for Embedded and Mobile
    Replies: 12
    Last Post: 22nd July 2010, 12:42
  2. howto send a reply using QDBusMessage
    By HERC in forum Qt Programming
    Replies: 2
    Last Post: 23rd February 2010, 16:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.