From 86eadb4d1bc2ac29b98ee6e7d07ce469f985ac10 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Thu, 23 Jul 2020 12:48:56 +0200 Subject: [PATCH] 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 --- src/plugins/cpaster/dpastedotcomprotocol.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/cpaster/dpastedotcomprotocol.cpp b/src/plugins/cpaster/dpastedotcomprotocol.cpp index aac23984982..c5927c58f33 100644 --- a/src/plugins/cpaster/dpastedotcomprotocol.cpp +++ b/src/plugins/cpaster/dpastedotcomprotocol.cpp @@ -56,7 +56,12 @@ void DPasteDotComProtocol::fetchFinished(const QString &id, QNetworkReply * cons const int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if (status >= 300 && status <= 308 && status != 306) { 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] { fetchFinished(id, newRep, true); });