Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt unable to get redirected url response
Forum Updated to NodeBB v4.3 + New Features

Qt unable to get redirected url response

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 6.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vivekmalik2466
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      something like "that":http://www.developer.nokia.com/Community/Wiki/Handling_an_HTTP_redirect_with_QNetworkAccessManager ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rishygupta
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SetBetterPass
          wrote on last edited by
          #4

          @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?

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rishygupta
            wrote on last edited by
            #5

            try this with redirected url
            QNetworkRequest requestCover;
            requestCover.setUrl(QUrl(coverurl));
            requestCover.setRawHeader( "User-Agent" , "Mozilla Firefox" );

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved