Skip to content

Commit

Permalink
The json-decorator-scope didn't set the user-agent yet.
Browse files Browse the repository at this point in the history
Add the header-dictionaries from base (which should've got the User-Agent set, at the very least in case we wrap around something that inherits from DefaultUserAgentScope, which is the only use-case I encountered) with the json-specific settings that are already in there. In order to prevent breaking the API, don't directly change the inheritance of the JsonDecoratorScope, but instead check for the existance of the header-dict in the base.

CURA-12067
  • Loading branch information
rburema committed Aug 15, 2024
1 parent fec6c5b commit aae8928
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions UM/TaskManagement/HttpRequestScope.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def __init__(self, base: HttpRequestScope) -> None:
"Content-Type": "application/json",
"Accept": "application/json"
}
# JsonDecorator probably _should_ have inherited from DefaultUserAgentScope in the first place.
# In order to prevent a break in the API by forcing that, just check if there are extra header specs needed.
if hasattr(self.base, "header_dict"):
self.header_dict.update(self.base.header_dict)

def requestHook(self, request: QNetworkRequest) -> None:
# not calling super().request_hook() because base will do that.
Expand Down

0 comments on commit aae8928

Please sign in to comment.