From 665ac49ea66f57062721a971ff6f0208c364990b Mon Sep 17 00:00:00 2001 From: Daniel Svensson Date: Wed, 13 Oct 2021 15:24:36 +0200 Subject: [PATCH] Add ServiceBaseUri to BinaryHttpDomainClientFactory constructor (#319) * Add ServiceBaseUri to BinaryHttpDomainClientFactory constructor --- .../BinaryHttpDomainClientFactory.cs | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/OpenRiaServices.Client.DomainClients.Http/Framework/BinaryHttpDomainClientFactory.cs b/src/OpenRiaServices.Client.DomainClients.Http/Framework/BinaryHttpDomainClientFactory.cs index 6e2364249..bdcabfd90 100644 --- a/src/OpenRiaServices.Client.DomainClients.Http/Framework/BinaryHttpDomainClientFactory.cs +++ b/src/OpenRiaServices.Client.DomainClients.Http/Framework/BinaryHttpDomainClientFactory.cs @@ -13,35 +13,26 @@ public class BinaryHttpDomainClientFactory { private readonly Func _httpClientFactory; - // not all platforms (blazor) support the cookiecontainer and it might be better if the end user configures - // their messagehandler/httpclient to match the applications requirement instead of getting runtime exceptions - private BinaryHttpDomainClientFactory() - : this(new HttpClientHandler() - { - CookieContainer = new System.Net.CookieContainer(), - UseCookies = true, - AutomaticDecompression = System.Net.DecompressionMethods.Deflate | System.Net.DecompressionMethods.GZip, - }) - { - } - /// /// Create a where all requests share a single /// IMPORTANT: To handle DNS updates you need to configure System.Net.ServicePointManager.ConnectionLeaseTimeout on .Net framework /// + /// The value base all service Uris on (see ) /// to be shared by all requests, /// if uncertain create a and enable cookies and compression - public BinaryHttpDomainClientFactory(HttpMessageHandler messageHandler) - : this(() => new HttpClient(messageHandler, disposeHandler: false)) + public BinaryHttpDomainClientFactory(Uri serverBaseUri, HttpMessageHandler messageHandler) + : this(serverBaseUri, () => new HttpClient(messageHandler, disposeHandler: false)) { } /// /// Constructor intended for .Net Core where the actual creation is handled by IHttpClientFactory or similar /// + /// The value base all service Uris on (see ) /// method creating a new HttpClient each time, should never return null - public BinaryHttpDomainClientFactory(Func httpClientFactory) + public BinaryHttpDomainClientFactory(Uri serverBaseUri, Func httpClientFactory) { + base.ServerBaseUri = serverBaseUri; this._httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory)); }