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. QNetworkReply and error 202
Forum Updated to NodeBB v4.3 + New Features

QNetworkReply and error 202

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.7k 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.
  • A Offline
    A Offline
    AndreaConte
    wrote on last edited by
    #1

    HI to all
    i don't understand because if i download i file from a link with my browsers i can get it and with my qt application i have always Error 202 (actaully analyzing with wireshark i got 403: permission denied as response)...is there something i'm ignoring?
    i can paste my code here:
    @bool YtDownloader::getFile()
    {
    url = "some_address_here" ;

    video = false;
    
    QString local = QFileInfo( url.path() ).fileName();
    
    if(local.isEmpty())
    {
        local = "get.out";
    }
    
    file.setFileName(local);
    
    if(!file.open(QIODevice::WriteOnly))
    {
        ui->lbDownloaded->setText("Error opening info file");
        return false;
    }
    
    request.setUrl( url );
    
    ui->btnDownload->setEnabled(false);
    
    startDownload();
    
    return true;
    

    }

    void YtDownloader::startDownload()
    {

    reply = manager->get(request);
    
    if(video)
    {
        ui->lbDownloaded->setText("Downloadingf file");
    }
    else
    {
        ui->lbDownloaded->setText("Downloading info");
    }
    
    connect(reply,SIGNAL(readyRead()),this,SLOT(scriviBytes()));
    connect(reply, SIGNAL(finished()), this, SLOT(downloadFinished()));
    connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadBar(qint64, qint64)));
    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(printNotOk(QNetworkReply::NetworkError)));
    

    }

    void YtDownloader::downloadFinished()
    {
    QVariant possibleRedirectUrl=reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
    if(!possibleRedirectUrl.toString().isEmpty())
    {
    url = reply->url();
    file.close();
    QFile::remove(file.fileName());
    QString filename = QFileInfo( url.path() ).fileName();
    file.setFileName(filename);
    if(!file.open(QIODevice::WriteOnly))
    {
    ui->lbDownloaded->setText("Error opening file after redirectt");
    return ;
    }
    request.setUrl(possibleRedirectUrl.toString());
    startDownload();
    }
    else
    {
    reply->close();
    file.write(reply->readAll());
    file.close();
    reply->deleteLater();
    ui->btnDownload->setEnabled(true);
    if(video)
    {
    ui->lbDownloaded->setText("File Downloaded");
    emit done();
    }
    else
    {
    ui->lbDownloaded->setText("Info Downloaded");
    replaceFile();
    }
    }
    }@

    My app downloads a file from internet, opens it (with replaceFile() and gets real file address...and when i try to get the file (not more the info file) i get error 202...but I tried with my browser and the link is correct! help me :)

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fluca1978
      wrote on last edited by
      #2

      Are you trying to build a youtube downloader?
      I don't know exactly how youtube provides content, I suggest you observe how some downloaders do their http queries against the site.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AndreaConte
        wrote on last edited by
        #3

        you guessed, but analyzing chrome http request with wireshark i didn't notice nothing unusual...my application receive 403 error immediatly after 'get' request...i thought it was a user-agent problem, but i have copied chrome ones...
        anyway QNAM maintains cookies automatically and represents it when asked by the server, doesn't it?

        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