Results 1 to 20 of 34

Thread: QNetworkAccessManager and redirections

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Location
    Valladolid, Spain
    Posts
    125
    Thanks
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QNetworkAccessManager and redirections

    I have problems handling redirects using QNetworkAccessManager. Could I get some help? Example code here: http://pastebin.com/bu7rWx2X

    I can't get the file that I want (hosted on sourceforge) using the first link in the code, but if I use the second link (commented), I get the file without problems.

    I know that this is almost only-c++-code forum, but the code is ~50 lines and I haven't used python-specific things. Only Qt calls.

    Thanks

  2. #2
    Join Date
    Jul 2009
    Location
    Valladolid, Spain
    Posts
    125
    Thanks
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QNetworkAccessManager and redirections

    Not a single reply? Nobody knows something about QNAM and redirections?

  3. #3
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QNetworkAccessManager and redirections

    I looked briefly on Your code, so maybe I'm wrong on this - also tired from all day work ;/, but why do You use https for sourceforge?, try http.
    Also try to use WireShark and capture Your request and browser request and compare both. That's probably fastest way to figure out why this don't work.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  4. The following user says thank you to Talei for this useful post:

    alexandernst (22nd September 2010)

  5. #4
    Join Date
    Jul 2009
    Location
    Valladolid, Spain
    Posts
    125
    Thanks
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QNetworkAccessManager and redirections

    I use https because that's the link. Qt should be able to manage that link. Also, going the Wireshark way is way too wrong for that problem. That is clearly a Qt bug.
    Both wget and curl are perfectly able to handle that link, so Qt should be able to handle it too. Could somebody try to run the code or maybe even better, point me to the right direction.

  6. #5
    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: QNetworkAccessManager and redirections

    Maybe you need to handle the redirection yourself. I'm not sure QNetworkAccessManager does that on its own. There are situations when you'd like to know a redirection is in place and not actually follow it blindly so I guess it could be that QNetworkAccessManager will not make the second request automatically.
    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.


  7. The following user says thank you to wysota for this useful post:

    alexandernst (22nd September 2010)

  8. #6
    Join Date
    Jul 2009
    Location
    Valladolid, Spain
    Posts
    125
    Thanks
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QNetworkAccessManager and redirections

    wysota, I already handle the redirections. I'm here because I'm doing something wrong and I need and example/advice.

  9. #7
    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: QNetworkAccessManager and redirections

    So what happens exactly if you use the first link? Did you connect appropriate signals and slots regarding handling ssl errors as it says in the docs?
    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.


  10. The following user says thank you to wysota for this useful post:

    alexandernst (22nd September 2010)

  11. #8
    Join Date
    Jul 2009
    Location
    Valladolid, Spain
    Posts
    125
    Thanks
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QNetworkAccessManager and redirections

    Yes, I connected the appropriate signals. I also manage sslErrors signal, but no ssl errors happen at all.
    In my app I get a 302 with the same URL but http instead of https. Then I get a 200 with exactly the same URL as from the 302 redirection. And it stops there.

    Using wget I get 302, 302, 302 and then 200. I also saw a cookie, but I don't know how to implement/use them with my code. I haven't found any example about doing that.

  12. #9
    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: QNetworkAccessManager and redirections

    Quote Originally Posted by alexandernst View Post
    Then I get a 200 with exactly the same URL as from the 302 redirection. And it stops there.
    And what would you expect? 200 is the last status code in chain, there are no more requests after that. Did you look at the headers you get with the response?
    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.


  13. The following user says thank you to wysota for this useful post:

    alexandernst (22nd September 2010)

  14. #10
    Join Date
    Jul 2009
    Location
    Valladolid, Spain
    Posts
    125
    Thanks
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QNetworkAccessManager and redirections

    I'm not sure if I'm looking them the right way. I use this:

    for item in reply.rawHeaderList():
    print "HEADER: " + reply.rawHeader(str(item))

  15. #11
    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: QNetworkAccessManager and redirections

    And what do you get?
    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.


  16. The following user says thank you to wysota for this useful post:

    alexandernst (22nd September 2010)

Similar Threads

  1. QNetworkAccessManager within QThread
    By Tomdarkness in forum Newbie
    Replies: 17
    Last Post: 26th August 2014, 15:12
  2. qnetworkaccessmanager problem!
    By novamaster in forum Qt Programming
    Replies: 6
    Last Post: 7th August 2010, 11:46
  3. QNetworkAccessManager question
    By _Stefan in forum Qt Programming
    Replies: 1
    Last Post: 5th March 2010, 12:21
  4. QNetworkAccessManager or QHttp
    By mind_freak in forum Qt Programming
    Replies: 3
    Last Post: 29th September 2009, 20:24
  5. How to Login using QNetworkAccessManager?
    By cydside in forum Newbie
    Replies: 1
    Last Post: 31st August 2009, 21:41

Tags for this Thread

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.