Esempio n. 1
0
        public RpcClient(Uri baseUrl, AuthenticationHeaderValue authHeaderValue = null,
                         JsonSerializerSettings jsonSerializerSettings          = null, HttpClientHandler httpClientHandler = null, ILog log = null)
        {
            _baseUrl = baseUrl;

            if (authHeaderValue == null)
            {
                authHeaderValue = BasicAuthenticationHeaderHelper.GetBasicAuthenticationHeaderValueFromUri(baseUrl);
            }

            _authHeaderValue = authHeaderValue;

            if (jsonSerializerSettings == null)
            {
                jsonSerializerSettings = DefaultJsonSerializerSettingsFactory.BuildDefaultJsonSerializerSettings();
            }

            _jsonSerializerSettings = jsonSerializerSettings;
            _httpClientHandler      = httpClientHandler;
            _log = log;

#if NETCOREAPP2_1 || NETCOREAPP3_1 || NET5_0_OR_GREATER
            _httpClient        = CreateNewHttpClient();
            _rotateHttpClients = false;
#else
            CreateNewRotatedHttpClient();
#endif
        }
Esempio n. 2
0
        public RpcClient(Uri baseUrl, HttpClient httpClient, AuthenticationHeaderValue authHeaderValue = null,
                         JsonSerializerSettings jsonSerializerSettings = null, ILog log = null)
        {
            _baseUrl = baseUrl;

            if (authHeaderValue == null)
            {
                authHeaderValue = BasicAuthenticationHeaderHelper.GetBasicAuthenticationHeaderValueFromUri(baseUrl);
            }

            _authHeaderValue = authHeaderValue;
            if (jsonSerializerSettings == null)
            {
                jsonSerializerSettings = DefaultJsonSerializerSettingsFactory.BuildDefaultJsonSerializerSettings();
            }
            _jsonSerializerSettings = jsonSerializerSettings;
            _log = log;
            InitialiseHttpClient(httpClient);
            _httpClient        = httpClient;
            _rotateHttpClients = false;
        }