diff --git a/Duplicati/Library/Backend/Backblaze/B2.cs b/Duplicati/Library/Backend/Backblaze/B2.cs index a819b10c9..8447b7ed5 100644 --- a/Duplicati/Library/Backend/Backblaze/B2.cs +++ b/Duplicati/Library/Backend/Backblaze/B2.cs @@ -322,7 +322,7 @@ public class B2 : IStreamingBackend using var request = new HttpRequestMessage(HttpMethod.Post, uploadUrlData.UploadUrl); using var timeoutStream = stream.ObserveReadTimeout(_timeouts.ReadWriteTimeout, false); - request.Headers.TryAddWithoutValidation("Authorization", uploadUrlData.AuthorizationToken); + request.Headers.Add("Authorization", uploadUrlData.AuthorizationToken); request.Headers.Add("X-Bz-Content-Sha1", sha1); request.Headers.Add("X-Bz-File-Name", _urlencodedPrefix + Utility.Uri.UrlPathEncode(remotename)); request.Content = new StreamContent(timeoutStream, B2_RECOMMENDED_CHUNK_SIZE); diff --git a/Duplicati/Library/Backend/Backblaze/B2AuthHelper.cs b/Duplicati/Library/Backend/Backblaze/B2AuthHelper.cs index 0b569ede8..420b5ea01 100644 --- a/Duplicati/Library/Backend/Backblaze/B2AuthHelper.cs +++ b/Duplicati/Library/Backend/Backblaze/B2AuthHelper.cs @@ -81,7 +81,7 @@ public class B2AuthHelper(string userid, string password, HttpClient httpClient, { var request = await base.CreateRequestAsync(url, method, cancellationToken).ConfigureAwait(false); var config = await GetConfigAsync(cancellationToken).ConfigureAwait(false); - request.Headers.TryAddWithoutValidation("Authorization", config.AuthorizationToken); + request.Headers.Add("Authorization", config.AuthorizationToken); request.Headers.Add("User-Agent", UserAgent); return request; } diff --git a/Duplicati/Library/Backend/Dropbox/DropboxHelper.cs b/Duplicati/Library/Backend/Dropbox/DropboxHelper.cs index 76d69e48d..eac4c9e68 100644 --- a/Duplicati/Library/Backend/Dropbox/DropboxHelper.cs +++ b/Duplicati/Library/Backend/Dropbox/DropboxHelper.cs @@ -90,7 +90,7 @@ namespace Duplicati.Library.Backend private async Task CreateChunkRequestAsync(string url, T arg, CancellationToken cancelToken) { var req = await CreateRequestAsync(url, HttpMethod.Post, cancelToken).ConfigureAwait(false); - req.Headers.TryAddWithoutValidation(API_ARG_HEADER, System.Text.Json.JsonSerializer.Serialize(arg)); + req.Headers.Add(API_ARG_HEADER, System.Text.Json.JsonSerializer.Serialize(arg)); req.Options.Set(FileRequestOption, true); return req; } @@ -165,7 +165,7 @@ namespace Duplicati.Library.Backend { var req = await CreateRequestAsync(WebApi.Dropbox.DownloadFilesUrl(), HttpMethod.Post, cancelToken).ConfigureAwait(false); req.Options.Set(FileRequestOption, true); - req.Headers.TryAddWithoutValidation(API_ARG_HEADER, System.Text.Json.JsonSerializer.Serialize(new PathArg { path = path })); + req.Headers.Add(API_ARG_HEADER, System.Text.Json.JsonSerializer.Serialize(new PathArg { path = path })); using (var response = await Utility.Utility.WithTimeout(m_timeouts.ShortTimeout, cancelToken, ct => GetResponseAsync(req, HttpCompletionOption.ResponseHeadersRead, ct)).ConfigureAwait(false)) { @@ -181,7 +181,7 @@ namespace Duplicati.Library.Backend { using var req = await CreateRequestAsync(WebApi.Dropbox.DeleteUrl(), HttpMethod.Post, ct).ConfigureAwait(false); req.Options.Set(FileRequestOption, true); - req.Headers.TryAddWithoutValidation(API_ARG_HEADER, System.Text.Json.JsonSerializer.Serialize(new PathArg { path = path })); + req.Headers.Add(API_ARG_HEADER, System.Text.Json.JsonSerializer.Serialize(new PathArg { path = path })); using var response = await GetResponseAsync(req, HttpCompletionOption.ResponseContentRead, ct).ConfigureAwait(false); }).ConfigureAwait(false); } diff --git a/Duplicati/Library/Backend/Jottacloud/Jottacloud.cs b/Duplicati/Library/Backend/Jottacloud/Jottacloud.cs index 659dc9bfb..da33db843 100644 --- a/Duplicati/Library/Backend/Jottacloud/Jottacloud.cs +++ b/Duplicati/Library/Backend/Jottacloud/Jottacloud.cs @@ -594,8 +594,8 @@ public class Jottacloud : IStreamingBackend var fileSize = stream.Length; using var req = await CreateRequest(HttpMethod.Post, remotename, "umode=nomultipart", true, cancelToken).ConfigureAwait(false); - req.Headers.TryAddWithoutValidation("JMd5", md5Hash); // Not required, but it will make the server verify the content and mark the file as corrupt if there is a mismatch. - req.Headers.TryAddWithoutValidation("JSize", fileSize.ToString()); // Required, and used to mark file as incomplete if we upload something be the total size of the original file! + req.Headers.Add("JMd5", md5Hash); // Not required, but it will make the server verify the content and mark the file as corrupt if there is a mismatch. + req.Headers.Add("JSize", fileSize.ToString()); // Required, and used to mark file as incomplete if we upload something be the total size of the original file! await using var timeoutStream = stream.ObserveReadTimeout(this.m_timeouts.ReadWriteTimeout, false); req.Content = new StreamContent(timeoutStream); diff --git a/Duplicati/Library/Backend/OAuthHelper/OAuthHelperHttpClient.cs b/Duplicati/Library/Backend/OAuthHelper/OAuthHelperHttpClient.cs index 4ee7d77d1..e28456c2e 100644 --- a/Duplicati/Library/Backend/OAuthHelper/OAuthHelperHttpClient.cs +++ b/Duplicati/Library/Backend/OAuthHelper/OAuthHelperHttpClient.cs @@ -136,7 +136,7 @@ public class OAuthHelperHttpClient : JsonWebHelperHttpClient return await Utility.Utility.WithTimeout(AUTHENTICATION_TIMEOUT, cancellationToken, async ct => { - request.Headers.TryAddWithoutValidation("X-AuthID", _Authid); + request.Headers.Add("X-AuthID", _Authid); response = await _httpClient.SendAsync(request, ct).ConfigureAwait(false); response.EnsureSuccessStatusCode();