From db1d4d9df0370f0944149f24b76fbb035bd48421 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Thu, 15 Aug 2024 15:29:30 +0200 Subject: [PATCH 1/2] Unless scope is overridden, always send a user-agent with HTTP(S) get/put. We can't forget to do that anymore -- previously we could, since a 'None' 'scope' would just not make headers, so each time we didn't set a scope (which we don't have to, since it's an optional parameter) no user-agent would get sent. CURA-12067 --- UM/TaskManagement/HttpRequestManager.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/UM/TaskManagement/HttpRequestManager.py b/UM/TaskManagement/HttpRequestManager.py index 155496ca9..7e0f96df9 100644 --- a/UM/TaskManagement/HttpRequestManager.py +++ b/UM/TaskManagement/HttpRequestManager.py @@ -286,8 +286,11 @@ def _createRequest(self, http_method: str, url: str, for key, value in headers_dict.items(): request.setRawHeader(key.encode("utf-8"), value.encode("utf-8")) - if scope is not None: - scope.requestHook(request) + if scope is None: + from UM.TaskManagement.HttpRequestScope import DefaultUserAgentScope + from UM.Application import Application + scope = DefaultUserAgentScope(Application.getInstance()) + scope.requestHook(request) # Generate a unique request ID request_id = uuid.uuid4().hex From 2d82491be01e4ae549791fa50f934d01104c7419 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Thu, 15 Aug 2024 15:41:47 +0200 Subject: [PATCH 2/2] Move imports to top of class (not a circular import). done as part of CURA-12067 --- UM/TaskManagement/HttpRequestManager.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/UM/TaskManagement/HttpRequestManager.py b/UM/TaskManagement/HttpRequestManager.py index 7e0f96df9..e80754bfb 100644 --- a/UM/TaskManagement/HttpRequestManager.py +++ b/UM/TaskManagement/HttpRequestManager.py @@ -11,9 +11,10 @@ from PyQt6.QtCore import QObject, QUrl, Qt, pyqtSignal, pyqtProperty from PyQt6.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply +from UM.Application import Application from UM.Logger import Logger from UM.TaskManagement.HttpRequestData import HttpRequestData -from UM.TaskManagement.HttpRequestScope import HttpRequestScope +from UM.TaskManagement.HttpRequestScope import DefaultUserAgentScope, HttpRequestScope from UM.TaskManagement.TaskManager import TaskManager @@ -287,8 +288,6 @@ def _createRequest(self, http_method: str, url: str, request.setRawHeader(key.encode("utf-8"), value.encode("utf-8")) if scope is None: - from UM.TaskManagement.HttpRequestScope import DefaultUserAgentScope - from UM.Application import Application scope = DefaultUserAgentScope(Application.getInstance()) scope.requestHook(request)