refactor(BaseHttpClientService): Verwendung von IEnumerable<KeyValuePair<string, object>> anstelle von Dictionary<string, string> in queryParams, form und headers inputs der FetchAsync Methode
This commit is contained in:
@@ -30,11 +30,11 @@ namespace DigitalData.Core.Client
|
||||
string? scheme = null,
|
||||
int? port = null,
|
||||
string path = "",
|
||||
Dictionary<string, object?>? queryParams = null,
|
||||
IEnumerable<KeyValuePair<string, object?>>? queryParams = null,
|
||||
HttpMethod? method = null,
|
||||
HttpContent? body = null,
|
||||
Dictionary<string, string>? form = null,
|
||||
Dictionary<string, string>? headers = null,
|
||||
IEnumerable<KeyValuePair<string, object>>? form = null,
|
||||
IEnumerable<KeyValuePair<string, object>>? headers = null,
|
||||
bool sendWithCookie = true,
|
||||
bool saveCookie = true
|
||||
)
|
||||
@@ -76,7 +76,7 @@ namespace DigitalData.Core.Client
|
||||
var requestMessage = new HttpRequestMessage(method, requestUri);
|
||||
|
||||
// Add headers if provided
|
||||
headers?.ForEach(header => requestMessage.Headers.Add(header.Key, header.Value));
|
||||
headers?.ForEach(header => requestMessage.Headers.Add(header.Key, header.Value.ToString()));
|
||||
|
||||
// Add cookie to request
|
||||
if (sendWithCookie)
|
||||
@@ -94,7 +94,7 @@ namespace DigitalData.Core.Client
|
||||
else if (body != null)
|
||||
requestMessage.Content = body;
|
||||
else if (form != null)
|
||||
requestMessage.Content = new FormUrlEncodedContent(form);
|
||||
requestMessage.Content = new FormUrlEncodedContent(form.Select(e => KeyValuePair.Create(e.Key, e.Value.ToString())));
|
||||
|
||||
var response = await _client.SendAsync(requestMessage);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user