Important: Please read the Qt Code of Conduct -

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("");

    the response string is :

    &lt;title&gt;301 Moved Permanently&lt;/title&gt;
    <h1>Moved Permanently</h1>
    <p>The document has moved <a href="">here</a>.</p>
    <address>Apache Server at 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...":
    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 so its never resolved to the new redirect url that is :
     QUrl newUrl = reply->url().resolved(vStatusCodeV.toUrl());
     // so im getting endless loop here 

Log in to reply