public SdkHttpClient(HttpConfig config) { if (_httpClient != null) { return; } var handler = new HttpClientHandler { ClientCertificateOptions = ClientCertificateOption.Manual, ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => config.IgnoreSslVerification || policyErrors == SslPolicyErrors.None }; if (!string.IsNullOrEmpty(config.ProxyHost)) { handler.Proxy = InitProxy(config); } _httpClient = new HttpClient(new RetryHandler(handler)); ConfigClientTimeout(config); }
public T Build() { Client client = Activator.CreateInstance <T>(); if (this._credentials == null) { this._credentials = Credentials.GetCredentialFromEnvironment <T>(_credentialType[0]); } if (!_credentialType.Contains(this._credentials.GetType().Name)) { throw new ArgumentException( $"credential type error, support credential type is {Join(",", _credentialType)}"); } client.WithCredential(this._credentials) .WithEndPoint(this._endPoint) .WithHttpConfig(this._httpConfig ?? HttpConfig.GetDefaultConfig()); client.InitSdkHttpClient(this._httpHandler, this._enableLogging, this._logLevel); return((T)client); }
public ClientBuilder <T> WithHttpConfig(HttpConfig httpConfig) { this._httpConfig = httpConfig; return(this); }
private Client WithHttpConfig(HttpConfig httpConfig) { this._httpConfig = httpConfig; return(this); }
private Client WithCredential(Credentials credentials) { this._credential = credentials ?? throw new ArgumentNullException(CredentialsNull); this._httpConfig = HttpConfig.GetDefaultConfig(); return(this); }
public HwMessageHandlerFactory(HttpConfig httpConfig) { this._httpConfig = httpConfig; }