From b62b68257069881a7a50c55313b23db014ed605f Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Thu, 3 May 2018 13:33:32 +0200 Subject: [PATCH] Make Qt network redirects work in both 5.8 and 5.9+ --- plugins/Toolbox/src/Toolbox.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index a2a5b5fc34..718a205aa2 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -301,7 +301,12 @@ class Toolbox(QObject, Extension): Logger.log("i", "Toolbox: Attempting to download & install package from %s.", url) url = QUrl(url) self._download_request = QNetworkRequest(url) - self._download_request.setAttribute(QNetworkRequest.FollowRedirectsAttribute, True) + if hasattr(QNetworkRequest, "FollowRedirectsAttribute"): + # Patch for Qt 5.6-5.8 + self._download_request.setAttribute(QNetworkRequest.FollowRedirectsAttribute, True) + if hasattr(QNetworkRequest, "RedirectPolicyAttribute"): + # Patch for Qt 5.9+ + self._download_request.setAttribute(QNetworkRequest.RedirectPolicyAttribute, True) self._download_request.setRawHeader(*self._request_header) self._download_reply = self._network_manager.get(self._download_request) self.setDownloadProgress(0)