You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some cases it is necessary to adjust the HttpClientHandler that is used by HttpClient (e.g. using certificates, configure SSL etc.).
After walking through the code for a while I recognized that the HttpClient seems to be replaceable via ConnectionPreferences via
public HttpClient HttpService { get; set; }
Fine at first glance, but
this only sets one instance of an client. So looking at
var masterService = preferences.HttpService ?? DefaultService.Invoke();
var arasSerice = preferences.HttpService ?? DefaultService.Invoke();
shows that two separate clients are build, but if you set it via preferences there is only one client. I'm not sure if everything still works with a single instance.
2. There are places where the DefaultService is used, even if you set another client via preferences: public static IPromise<Stream> AsFile(this IReadOnlyProperty prop, IConnection conn, bool async) seems go always via the default client.
So my next idea was to implement a
public Action<HttpClientHandler> HttpClientHandlerEnricher
{
get => _httpClientHandlerEnricher ?? (h => { });
set => _httpClientHandlerEnricher = HttpClientHandlerEnricher;
}
This Action could be part of the ConnectionPreferences and then be called on the handlers. In first place this had to happed in the Factory itself, because (1.) and (2.), r.g.
static Factory()
{
DefaultService = () =>
{
var handler = new SyncClientHandler
{
CookieContainer = new CookieContainer()
};
ConnectionPreferences.HttpClientHandlerEnricher(handler);
Unfortunately the static initializer avoids that any ConnectionPreferences are set at that moment.
So I don't have a good idea of placing the handler-manipulating code. But maybe I'm missing something and there is already a solution for that.
The text was updated successfully, but these errors were encountered:
In some cases it is necessary to adjust the
HttpClientHandler
that is used byHttpClient
(e.g. using certificates, configure SSL etc.).After walking through the code for a while I recognized that the
HttpClient
seems to be replaceable viaConnectionPreferences
viaFine at first glance, but
shows that two separate clients are build, but if you set it via preferences there is only one client. I'm not sure if everything still works with a single instance.
2. There are places where the
DefaultService
is used, even if you set another client via preferences:public static IPromise<Stream> AsFile(this IReadOnlyProperty prop, IConnection conn, bool async)
seems go always via the default client.So my next idea was to implement a
This Action could be part of the
ConnectionPreferences
and then be called on the handlers. In first place this had to happed in theFactory
itself, because (1.) and (2.), r.g.Unfortunately the static initializer avoids that any
ConnectionPreferences
are set at that moment.So I don't have a good idea of placing the
handler
-manipulating code. But maybe I'm missing something and there is already a solution for that.The text was updated successfully, but these errors were encountered: