I'm trying to download a website (youtube) that opens after user passes the consent page (accepting cookies). So i create QNetworkRequest request and set RawHeader to ("COOKIE" , "CONSENT=YES+42"). It works fine, but only with the first attempt to download. With every next attempt i bounce against the consent page. The problem is somehow bypassed when each time i use deleteLater() on QNetworkAccessManager object. But the documentation claims "One QNetworkAccessManager instance should be enough for the whole Qt application" (also creating new instance of QNetworkAccessManager for each use eventually results with not receiving a replay and rise of processor use). So my question is how to "reset" QNetworkAccessManager so with each next use, it acts as with the first request. My code looks like this:
Qt Code:
  1. Youtube::Youtube(QObject *parent) : QObject(parent)
  2. {
  3. manager = new QNetworkAccessManager(this);
  4. }
  5.  
  6. void Youtube::makeRequest(QString indexCore){
  7. QNetworkReply *reply;
  8. QNetworkRequest request;
  9. connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotReadyRead(QNetworkReply*)));
  10. request.setRawHeader("COOKIE" , "CONSENT=YES+42" ); //works
  11. request.setUrl(QUrl("https://" + indexCore ));
  12. reply = manager->get(request);
  13. }
  14.  
  15. void Youtube::slotReadyRead(QNetworkReply *replay)
  16. {
  17. QByteArray dataTemp = replay->readAll();
  18. website = dataTemp.toStdString();
  19. replay->deleteLater();
  20. }
To copy to clipboard, switch view to plain text mode