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");
reply->readAll()the response string is :
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>301 Moved Permanently</title> </head><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> </body></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); }@