From 723f5c493ed941ba3946e9b9665f55e708817eff Mon Sep 17 00:00:00 2001 From: Akira Ohgaki <akiraohgaki@gmail.com> Date: Sat, 15 Oct 2016 09:08:06 +0900 Subject: [PATCH] Follow URL redirection --- src/handlers/xdgurl.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/handlers/xdgurl.cpp b/src/handlers/xdgurl.cpp index 57446a8..c5d4dbf 100644 --- a/src/handlers/xdgurl.cpp +++ b/src/handlers/xdgurl.cpp @@ -225,7 +225,15 @@ void XdgUrl::_downloaded(QNetworkReply *reply) return; } - // If the network reply has a refresh header, retry download + if (reply->hasRawHeader("Location")) { + QString redirectUrl = QString(reply->rawHeader("Location")); + if (redirectUrl.startsWith("/")) { + redirectUrl = reply->url().authority() + redirectUrl; + } + _network->get(QUrl(redirectUrl)); + return; + } + if (reply->hasRawHeader("Refresh")) { QString refreshUrl = QString(reply->rawHeader("Refresh")).split("url=").last(); if (refreshUrl.startsWith("/")) { -- GitLab