Removed use of TryAddWithoutValidation as it can hide cases where the headers are not set.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Duplicati.Library.Backend
|
||||
private async Task<HttpRequestMessage> CreateChunkRequestAsync<T>(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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user