extensionDownloader: Use POST request for checking updates

Usage of GET requests for checking updates was made deprecated
at website some time ago [1], but REST endpoint was
CSRF-protected until recently [2].
The body of update request may be big enough and thus does not
suitable for GET requests.

[1] 0b38da1b2b
[2] e3ab0c07dc

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1781>
This commit is contained in:
Yuri Konotopov 2021-03-29 22:42:42 +04:00
parent 687b84c90a
commit 02b06385ea

View File

@ -151,12 +151,19 @@ function checkForUpdates() {
'disable-extension-version-validation');
let params = {
shell_version: Config.PACKAGE_VERSION,
installed: JSON.stringify(metadatas),
disable_version_validation: versionCheck.toString(),
};
let url = REPOSITORY_URL_UPDATE;
let message = Soup.form_request_new_from_hash('GET', url, params);
const uri = Soup.URI.new(REPOSITORY_URL_UPDATE);
uri.set_query_from_form(params);
const message = Soup.Message.new_from_uri('POST', uri);
message.set_request(
'application/json',
Soup.MemoryUse.COPY,
JSON.stringify(metadatas)
);
_httpSession.queue_message(message, () => {
if (message.status_code != Soup.KnownStatusCode.OK)
return;