internal static ILineProtocolClient CreateClient( AliTSDBOptions influxDbOptions, HttpPolicy httpPolicy, HttpMessageHandler httpMessageHandler = null) { var httpClient = httpMessageHandler == null ? new HttpClient() : new HttpClient(httpMessageHandler); httpClient.BaseAddress = new Uri(influxDbOptions.Endpoint); if (string.IsNullOrWhiteSpace(influxDbOptions.UserName) || string.IsNullOrWhiteSpace(influxDbOptions.Password)) { return(new DefaultLineProtocolClient( influxDbOptions, httpClient)); } var byteArray = Encoding.ASCII.GetBytes($"{influxDbOptions.UserName}:{influxDbOptions.Password}"); //httpClient.BaseAddress = influxDbOptions.BaseUri; //httpClient.Timeout = httpPolicy.Timeout; //httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray)); return(new DefaultLineProtocolClient( influxDbOptions, httpClient)); }
public DefaultLineProtocolClient(AliTSDBOptions aliTSDBOptions, HttpClient httpClient) { _aliTSDBOptions = aliTSDBOptions ?? throw new ArgumentNullException(nameof(aliTSDBOptions)); _httpClient = httpClient; }