Handle redirects when downloading Spotify blob.

Use the NoLessSafeRedirectPolicy policy which will redirect as long as it isn't
from https to http.
This commit is contained in:
Jim Broadus 2020-03-22 19:59:21 -07:00 committed by John Maguire
parent 94eb2dcfc1
commit a85b3531c3
1 changed files with 7 additions and 1 deletions

View File

@ -95,7 +95,13 @@ void SpotifyBlobDownloader::Start() {
filename);
qLog(Info) << "Downloading" << url;
QNetworkReply* reply = network_->get(QNetworkRequest(url));
QNetworkRequest req(url);
// This policy will work as long as there isn't a redirect from https to
// http.
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute,
QNetworkRequest::NoLessSafeRedirectPolicy);
QNetworkReply* reply = network_->get(req);
connect(reply, SIGNAL(finished()), SLOT(ReplyFinished()));
connect(reply, SIGNAL(downloadProgress(qint64, qint64)),
SLOT(ReplyProgress()));