CPaster: Inform about a permanent redirect

Helps to keep track of the current workaround and replace
it again with using the updated URL on a permanent move.

Change-Id: I913dbd7be18d77c9a8d52f1dd931cc5b30320fa2
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Christian Stenger
2020-07-23 12:48:56 +02:00
parent 27514fa94d
commit 86eadb4d1b

View File

@@ -56,7 +56,12 @@ void DPasteDotComProtocol::fetchFinished(const QString &id, QNetworkReply * cons
const int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); const int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (status >= 300 && status <= 308 && status != 306) { if (status >= 300 && status <= 308 && status != 306) {
if (!alreadyRedirected) { if (!alreadyRedirected) {
QNetworkReply * const newRep = httpGet(QString::fromUtf8(reply->rawHeader("Location"))); const QString location = QString::fromUtf8(reply->rawHeader("Location"));
if (status == 301 || status == 308) {
const QString m = QString("HTTP redirect (%1) to \"%2\"").arg(status).arg(location);
Core::MessageManager::write(m, Core::MessageManager::ModeSwitch);
}
QNetworkReply * const newRep = httpGet(location);
connect(newRep, &QNetworkReply::finished, this, [this, id, newRep] { connect(newRep, &QNetworkReply::finished, this, [this, id, newRep] {
fetchFinished(id, newRep, true); fetchFinished(id, newRep, true);
}); });