From 30bd0991f21ffaa887150068dd13d590bc14d913 Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Fri, 29 Oct 2021 17:09:40 +0200 Subject: [PATCH] More attempts --- src/fetcher.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/fetcher.cpp b/src/fetcher.cpp index f9db04ad..691beaef 100644 --- a/src/fetcher.cpp +++ b/src/fetcher.cpp @@ -168,9 +168,12 @@ QNetworkReply *Fetcher::download(const QString &url, const QString &filePath, co qDebug() << feed << allowInsecureRedirect; if (allowInsecureRedirect) { request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::UserVerifiedRedirectPolicy); + request.setAttribute(QNetworkRequest::Http2AllowedAttribute, true); } } + qDebug() << request.rawHeaderList(); + QFile *file = new QFile(filePath); if (file->exists() && file->size() > 0) { // try to resume download @@ -186,6 +189,14 @@ QNetworkReply *Fetcher::download(const QString &url, const QString &filePath, co QNetworkReply *reply = get(request); + connect(reply, &QNetworkReply::errorOccurred, this, [=]() { + qDebug() << "network error" << reply->errorString(); + }); + + connect(reply, &QNetworkReply::metaDataChanged, this, [=]() { + qDebug() << "metadata" << reply->rawHeaderPairs(); + }); + connect(reply, &QNetworkReply::readyRead, this, [=]() { qDebug() << "reading"; if (reply->isOpen() && file) { @@ -197,6 +208,11 @@ QNetworkReply *Fetcher::download(const QString &url, const QString &filePath, co connect(reply, &QNetworkReply::finished, this, [=]() { qDebug() << "done"; if (reply->isOpen() && file) { + qDebug() << "reading end"; + qDebug() << "metadata" << reply->rawHeaderPairs(); + qDebug() << reply->operation(); + qDebug() << reply->attribute(QNetworkRequest::RedirectionTargetAttribute); + qDebug() << reply->attribute(QNetworkRequest::QNetworkRequest::HttpStatusCodeAttribute); QByteArray data = reply->readAll(); file->write(data); file->close(); @@ -217,6 +233,7 @@ QNetworkReply *Fetcher::download(const QString &url, const QString &filePath, co if (allowInsecureRedirect) { connect(reply, &QNetworkReply::redirected, this, [=](const QUrl &url) { qDebug() << "checking for redirect" << url; + qDebug() << reply->attribute(QNetworkRequest::RedirectionTargetAttribute); if (allowInsecureRedirect) { qDebug() << "allowed"; Q_EMIT reply->redirectAllowed(); @@ -224,10 +241,6 @@ QNetworkReply *Fetcher::download(const QString &url, const QString &filePath, co }); } - connect(reply, &QNetworkReply::sslErrors, this, [=](const QList &errors) { - qDebug() << "ssl errors"; - }); - return reply; }