refactor(BaseHttpClientService): aktualisiert, um den Pfad zu initialisieren emty string, wenn es null ist und HttpClientOptions ohne IOptions hinzugefügt

This commit is contained in:
Developer 02 2024-11-25 10:51:59 +01:00
parent 3b8b315fea
commit ea3d1312b8

View File

@ -20,14 +20,14 @@ namespace DigitalData.Core.Client
protected IEnumerable<KeyValuePair<string, object?>>? _queryParams; protected IEnumerable<KeyValuePair<string, object?>>? _queryParams;
public BaseHttpClientService(HttpClient client, CookieContainer cookieContainer, IOptions<HttpClientOptions> clientOptions) public BaseHttpClientService(HttpClient client, CookieContainer cookieContainer, HttpClientOptions clientOptions)
{ {
_client = client; _client = client;
_cookies = cookieContainer; _cookies = cookieContainer;
_uri = clientOptions.Value.Uri.Trim(URI_TRIM_CHARS); _uri = clientOptions.Uri.Trim(URI_TRIM_CHARS);
_path = clientOptions.Value.Path.Trim(URI_TRIM_CHARS); _path = clientOptions.Path?.Trim(URI_TRIM_CHARS) ?? string.Empty;
_headers = clientOptions.Value.Headers; _headers = clientOptions.Headers;
_queryParams = clientOptions.Value.QueryParams; _queryParams = clientOptions.QueryParams;
} }
public CookieCollection GetCookies(string path = "") => _cookies.GetCookies(uri: new Uri(UriCombine(_uri, path, path.Trim(URI_TRIM_CHARS)))); public CookieCollection GetCookies(string path = "") => _cookies.GetCookies(uri: new Uri(UriCombine(_uri, path, path.Trim(URI_TRIM_CHARS))));