Пример #1
0
        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);
        }
Пример #2
0
            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);
            }
Пример #3
0
 public ClientBuilder <T> WithHttpConfig(HttpConfig httpConfig)
 {
     this._httpConfig = httpConfig;
     return(this);
 }
Пример #4
0
 private Client WithHttpConfig(HttpConfig httpConfig)
 {
     this._httpConfig = httpConfig;
     return(this);
 }
Пример #5
0
 private Client WithCredential(Credentials credentials)
 {
     this._credential = credentials ?? throw new ArgumentNullException(CredentialsNull);
     this._httpConfig = HttpConfig.GetDefaultConfig();
     return(this);
 }
Пример #6
0
 public HwMessageHandlerFactory(HttpConfig httpConfig)
 {
     this._httpConfig = httpConfig;
 }