aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cpaster
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2020-07-23 12:48:56 +0200
committerChristian Stenger <christian.stenger@qt.io>2020-07-23 12:42:52 +0000
commit86eadb4d1bc2ac29b98ee6e7d07ce469f985ac10 (patch)
treec8fa59e87230a4308b339224bbb447825c10af3e /src/plugins/cpaster
parent27514fa94d40905809cc2ab80935d77d61185165 (diff)
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>
Diffstat (limited to 'src/plugins/cpaster')
-rw-r--r--src/plugins/cpaster/dpastedotcomprotocol.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/cpaster/dpastedotcomprotocol.cpp b/src/plugins/cpaster/dpastedotcomprotocol.cpp
index aac2398498..c5927c58f3 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);
});