Qt QNetworkRequest::RedirectionTargetAttribute can't detect redirection

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

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

    the response string is :

    &lt;title&gt;301 Moved Permanently&lt;/title&gt;
    <h1>Moved Permanently</h1>
    <p>The document has moved <a href="http://siteexample.de/">here</a>.</p>
    <address>Apache Server at www.siteexample.de Port 80</address>

    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 

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.