Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt QNetworkRequest::RedirectionTargetAttribute can't detect redirection
Forum Update on Monday, May 27th 2025

Qt QNetworkRequest::RedirectionTargetAttribute can't detect redirection

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    umen242
    wrote on last edited by
    #1

    Im trying to do get request to web site , when i getting the site html in the :

    @ reply = m_networkManager->get("www.siteexample.de");
    reply->readAll()

    the response string is :

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    &lt;html&gt;&lt;head>
    &lt;title&gt;301 Moved Permanently&lt;/title&gt;
    &lt;/head&gt;&lt;body>
    <h1>Moved Permanently</h1>
    <p>The document has moved <a href="http://siteexample.de/">here</a>.</p>
    <hr>
    <address>Apache Server at www.siteexample.de Port 80</address>
    &lt;/body&gt;&lt;/html>@
    

    now in the finish slot i try to capture the redirect like this : ( based on the http example in Qt 4.8) and this link :
    "Your text to link here...":http://www.developer.nokia.com/Community/Wiki/Handling_an_HTTP_redirect_with_QNetworkAccessManager
    @
    QVariant vStatusCodeV = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);

    if(vStatusCodeV.toInt() == 200)
    {
      // do stuff ...
    } 
    else if (vStatusCodeV.toInt() == 301 || vStatusCodeV  == reply->attribute(QNetworkRequest::RedirectionTargetAttribute))
    {
     // its resoulved to to http://www.siteexample.de so its never resolved to the new redirect url that is : http://siteexample.de
     QUrl newUrl = reply->url().resolved(vStatusCodeV.toUrl());
     // so im getting endless loop here 
     startRequest(newUrl);
     
    }@
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved