Hi JeanC. I was dealing with the same issue right now.
You can check the reply object to see if the status code is 301 (redirect). If so there's a redirection url attribute that would be set to the target URL.
QVariant replyStatus
= reply
->attribute
(QNetworkRequest
::HttpStatusCodeAttribute);
//! If needs to redirect - download from updated url
if (replyStatus == 301)
{
QString redirectUrl
= reply
->attribute
(QNetworkRequest
::RedirectionTargetAttribute).
toString();
// HERE - just use the url for creating a new request
QVariant replyStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
//! If needs to redirect - download from updated url
if (replyStatus == 301)
{
QString redirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toString();
// HERE - just use the url for creating a new request
To copy to clipboard, switch view to plain text mode
Bookmarks