From eba5a7b197dca8b63984e9006cbbc90883db4a83 Mon Sep 17 00:00:00 2001 From: Vitalii Mikhailov Date: Sat, 2 Sep 2023 19:53:01 +0300 Subject: [PATCH] Fixed check --- src/NexusUploader/Services/ManageClient.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/NexusUploader/Services/ManageClient.cs b/src/NexusUploader/Services/ManageClient.cs index fd1d9c1..6298c8a 100644 --- a/src/NexusUploader/Services/ManageClient.cs +++ b/src/NexusUploader/Services/ManageClient.cs @@ -26,6 +26,7 @@ public async Task CheckValidSession() { var uri = "/Core/Libs/Common/Managers/Mods?GetDownloadHistory"; using var req = new HttpRequestMessage(HttpMethod.Post, uri); + req.Headers.Add("X-Requested-With", "XMLHttpRequest"); req.Content = new StringContent("", Encoding.UTF8); var resp = await _httpClient.SendAsync(req); if (!resp.IsSuccessStatusCode) @@ -40,7 +41,8 @@ public async Task AddChangelog(GameRef game, int modId, string version, st { changeMessage = HttpUtility.HtmlEncode(changeMessage).Replace(@"\n", "\n"); var uri = "/Core/Libs/Common/Managers/Mods?SaveDocumentation"; - var message = new HttpRequestMessage(HttpMethod.Post, uri); + using var message = new HttpRequestMessage(HttpMethod.Post, uri); + message.Headers.Add("X-Requested-With", "XMLHttpRequest"); message.Headers.Add("Referer", $"https://www.nexusmods.com/{game.Name}/mods/edit/?step=docs&id={modId}"); var content = new MultipartFormDataContent(); content.Add(new StringContent(game.Id.ToString()), "game_id"); @@ -69,7 +71,8 @@ public async Task AddChangelog(GameRef game, int modId, string version, st public async Task AddFile(GameRef game, int modId, UploadedFile upload, FileOptions options) { var uri = "/Core/Libs/Common/Managers/Mods?AddFile"; - var message = new HttpRequestMessage(HttpMethod.Post, uri); + using var message = new HttpRequestMessage(HttpMethod.Post, uri); + message.Headers.Add("X-Requested-With", "XMLHttpRequest"); message.Headers.Add("Referer", $"https://www.nexusmods.com/{game.Name}/mods/edit/?step=docs&id={modId}"); using var content = new MultipartFormDataContent(); content.Add(game.Id.ToContent(), "game_id");