Qt unable to get redirected url response
-
I want to download image by using this link
http://interactiveplaylist.com/art/mbidlarge.php?mbid=53ccdacc-3e3e-449b-995e-b280666dc28c
but on get method url it redirect to another url i.e. http://userserve-ak.last.fm/serve/174s/89255431.jpg, this url has the actual image that I want to download but it gives me error#406 because server is redirected.
I am using code as below:
@
QNetworkRequest requestCover;
requestCover.setUrl(QUrl(coverurl));
QNetworkAccessManager *downloadmanagerCover = new QNetworkAccessManagerr( parent);downloadreplyCover = downloadmanagerCover->get(requestCover); connect(downloadmanagerCover,SIGNAL(finished(QNetworkReply*)),this,SLOT(onFinishedCover(QNetworkReply*))); connect(downloadreplyCover,SIGNAL(readyRead()),this,SLOT(onReadyRead())); connect(downloadreplyCover,SIGNAL(finished()),this,SLOT(onReplyFinishedCover()));@
@
void AcoustidClient::onFinishedCover(QNetworkReply * reply)
{
switch(reply->error())
{
case QNetworkReply::NoError:
{}break; default:{ qDebug()<<"file is not downloaded successfully."<<newUrl; qDebug(reply->errorString().toLatin1()); }; } }
}@
Do anyone have any idea.
-
Hi,
something like "that":http://www.developer.nokia.com/Community/Wiki/Handling_an_HTTP_redirect_with_QNetworkAccessManager ?
-
I think its not problem of only redirection its different i tried http://www.wikipedia.org/wiki/URL_redirection link for redirection with help of "that":http://www.developer.nokia.com/Community/Wiki/Handling_an_HTTP_redirect_with_QNetworkAccessManager and got http://en.wikipedia.org/wiki/URL_redirection as redirected url but in case of http://interactiveplaylist.com/art/mbidlarge.php?mbid=53ccdacc-3e3e-449b-995e-b280666dc28c link its i got null relpy in redirected link
connect(downloadmanager,SIGNAL(finished(QNetworkReply*)),this,SLOT(onFinishedCover(QNetworkReply*)));
void class::onFinishedCover(QNetworkReply * reply)
{
QVariant possibleRedirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
}
possibleRedirectUrl is null in this case.may be other problem than only redirection
-
@QNetworkAccessManager *downloadmanagerCover = new QNetworkAccessManagerr( parent);@
2 r at the end of QNetworkAccessManager is just a typo when putting it here or you have it so in your code?
-
try this with redirected url
QNetworkRequest requestCover;
requestCover.setUrl(QUrl(coverurl));
requestCover.setRawHeader( "User-Agent" , "Mozilla Firefox" );