public static IClusterClient CreateClusterClient(IHttpClientConfiguration configuration, ILog log) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } return(new ClusterClient( log, config => { config.Logging.LogReplicaRequests = false; config.Logging.LogResultDetails = false; configuration.Apply(config); if (configuration.RetryStrategy != null) { var idempotentRequests = configuration.IdempotentRequests ?? HttpMethodBasedIdempotentRequestSpecification.OnlyGetMethodIsIdempotent; config.RetryPolicy = new AdHocRetryPolicy((request, _, _) => idempotentRequests.IsIdempotent(request)); config.RetryStrategyEx = new RetryStrategyExAdapter(configuration.RetryStrategy.CreateRetryStrategy()); } })); }
public AdunisWebHandler(IDevice device, IOAuthUtils oAuth, IHttpClientConfiguration httpClientConfiguration, IServiceApi serviceApi) { this.device = device; this.oAuth = oAuth; this.httpClientConfiguration = httpClientConfiguration; this.serviceApi = serviceApi; }
private BandwidthClient(TimeSpan timeout, string messagingBasicAuthUserName, string messagingBasicAuthPassword, string twoFactorAuthBasicAuthUserName, string twoFactorAuthBasicAuthPassword, string voiceBasicAuthUserName, string voiceBasicAuthPassword, string webRtcBasicAuthUserName, string webRtcBasicAuthPassword, Environment environment, string baseUrl, IDictionary <string, IAuthManager> authManagers, IHttpClient httpClient, IHttpClientConfiguration httpClientConfiguration) { messagingBasicAuthManager = new MessagingBasicAuthManager(messagingBasicAuthUserName, messagingBasicAuthPassword); twoFactorAuthBasicAuthManager = new TwoFactorAuthBasicAuthManager(twoFactorAuthBasicAuthUserName, twoFactorAuthBasicAuthPassword); voiceBasicAuthManager = new VoiceBasicAuthManager(voiceBasicAuthUserName, voiceBasicAuthPassword); webRtcBasicAuthManager = new WebRtcBasicAuthManager(webRtcBasicAuthUserName, webRtcBasicAuthPassword); Timeout = timeout; Environment = environment; BaseUrl = baseUrl; this.httpClient = httpClient; this.authManagers = new Dictionary <string, IAuthManager>(authManagers); HttpClientConfiguration = httpClientConfiguration; this.authManagers["messaging"] = messagingBasicAuthManager; this.authManagers["twoFactorAuth"] = twoFactorAuthBasicAuthManager; this.authManagers["voice"] = voiceBasicAuthManager; this.authManagers["webRtc"] = webRtcBasicAuthManager; messaging = new Lazy <MessagingClient>(() => new MessagingClient(this)); twoFactorAuth = new Lazy <TwoFactorAuthClient>(() => new TwoFactorAuthClient(this)); voice = new Lazy <VoiceClient>(() => new VoiceClient(this)); webRtc = new Lazy <WebRtcClient>(() => new WebRtcClient(this)); }
private MdNotesClient( TimeSpan timeout, Environment environment, string oAuthClientId, string oAuthRedirectUri, Models.OAuthToken oAuthToken, IDictionary <string, IAuthManager> authManagers, IHttpClient httpClient, IHttpClientConfiguration httpClientConfiguration) { this.Timeout = timeout; this.Environment = environment; this.httpClient = httpClient; this.authManagers = (authManagers == null) ? new Dictionary <string, IAuthManager>() : new Dictionary <string, IAuthManager>(authManagers); this.HttpClientConfiguration = httpClientConfiguration; this.service = new Lazy <ServiceController>( () => new ServiceController(this, this.httpClient, this.authManagers)); this.user = new Lazy <UserController>( () => new UserController(this, this.httpClient, this.authManagers)); if (this.authManagers.ContainsKey("global")) { this.implicitOAuthManager = (ImplicitOAuthManager)this.authManagers["global"]; } if (!this.authManagers.ContainsKey("global") || !this.ImplicitOAuthCredentials.Equals(oAuthClientId, oAuthRedirectUri)) { this.implicitOAuthManager = new ImplicitOAuthManager(oAuthClientId, oAuthRedirectUri, oAuthToken, this); this.authManagers["global"] = this.implicitOAuthManager; } }
internal SpecifyClientIdentification(IHttpClientConfiguration clientConfiguration, ICrypt cryptoProvider, RequestTimeouts?options, ILog log) { ClientConfiguration = clientConfiguration ?? throw new ArgumentNullException(nameof(clientConfiguration)); CryptoProvider = cryptoProvider; RequestTimeouts = options; Log = log; }
private SimpleCalculatorClient( TimeSpan timeout, Environment environment, string basicAuthUserName, string basicAuthPassword, IDictionary <string, IAuthManager> authManagers, IHttpClient httpClient, HttpCallBack httpCallBack, IHttpClientConfiguration httpClientConfiguration) { this.Timeout = timeout; this.Environment = environment; this.httpCallBack = httpCallBack; this.httpClient = httpClient; this.authManagers = (authManagers == null) ? new Dictionary <string, IAuthManager>() : new Dictionary <string, IAuthManager>(authManagers); this.HttpClientConfiguration = httpClientConfiguration; this.client = new Lazy <APIController>( () => new APIController(this, this.httpClient, this.authManagers, this.httpCallBack)); if (this.authManagers.ContainsKey("global")) { this.basicAuthManager = (BasicAuthManager)this.authManagers["global"]; } if (!this.authManagers.ContainsKey("global") || !this.BasicAuthCredentials.Equals(basicAuthUserName, basicAuthPassword)) { this.basicAuthManager = new BasicAuthManager(basicAuthUserName, basicAuthPassword); this.authManagers["global"] = this.basicAuthManager; } }
public ValueTypeHttpClientRepositoryBase( IHttpClientConfiguration config, IAuthenticationHeaderGenerator authenticationHeaderGenerator, ILogger <ValueTypeHttpClientRepositoryBase <TIdentity, TNaturalKey, TItem> > logger = null) : base(config, authenticationHeaderGenerator, logger) { }
public CartClientProxy(IHttpClientConfiguration configuration, ServiceName serviceName) { _serviceName = serviceName.ToString(); BaseAddress = configuration.ApiBaseUri; DefaultRequestHeaders.Accept.Clear(); DefaultRequestHeaders.Accept.Add(configuration.MediaTypeWithQualityHeaderValue); }
public FilerWebHandler(IDevice device, IAccountService account, IOAuthUtils oAuth, IHttpClientConfiguration httpClientConfiguration, IServiceApi serviceApi) { this.device = device; this.account = account; this.oAuth = oAuth; this.httpClientConfiguration = httpClientConfiguration; this.serviceApi = serviceApi; }
public IHttpClient CreateClient(IHttpClientConfiguration configuration) { #if NET40 || NET35 return(new HttpClientWebClient(logger, configuration, threadSuspender)); // HttpClient is not available in .NET 3.5 and 4.0 #else return(new HttpClientHttpClient(logger, configuration, threadSuspender)); #endif }
internal static Builder ModifyWith(IHttpClientConfiguration httpClientConfig) { return(new Builder() .WithBaseUrl(httpClientConfig.BaseUrl) .WithApplicationId(httpClientConfig.ApplicationId) .WithTrustManager(httpClientConfig.SslTrustManager) .WithServerId(httpClientConfig.ServerId)); }
public BaseWebAPIDao(IHttpClientConfiguration configuration, IHttpClientConfiguration originalConfiguration, TWebAPIFinder finder) { _clientConfiguration = configuration; _originalConfiguration = originalConfiguration; _finder = finder; _finder.EnablePaging = false; _customAuthFunc = null; }
public MvxNativeFileDownloadRequest(string url, string downloadPath) { this.Url = url; this.DownloadPath = downloadPath; this.httpClientConfiguration = Mvx.Resolve <IHttpClientConfiguration>(); this.device = Mvx.Resolve <IDevice>(); this.serviceApi = Mvx.Resolve <IServiceApi>(); }
public HttpClientWrapper(IHttpClientConfiguration clientConfiguration) { if (clientConfiguration == null) { clientConfiguration = AHttpClientConfiguration.DefaultConfiguration; //set default communication ClientConfiguration } ClientConfiguration = clientConfiguration; }
protected HttpClient(ILogger logger, IHttpClientConfiguration configuration, IInterruptibleThreadSuspender threadSuspender) { this.logger = logger; this.threadSuspender = threadSuspender; HttpClientConfiguration = configuration; monitorUrl = BuildMonitorUrl(configuration.BaseUrl, configuration.ApplicationId, ServerId); newSessionUrl = BuildNewSessionUrl(configuration.BaseUrl, configuration.ApplicationId, ServerId); }
public HttpClientRepositoryBase( IHttpClientConfiguration config, IAuthenticationHeaderGenerator authenticationHeaderGenerator, ILogger <HttpClientRepositoryBase <TIdentity, TItem> > logger = null) { this.Config = config; this.AuthenticationHeaderGenerator = authenticationHeaderGenerator; this.Logger = logger; }
public HttpClient(IHttpClientConfiguration configuration) { if (configuration == null) { throw new NullReferenceException("Configuration cannot be null."); } _configuration = configuration; _baseAddress = new Uri(string.Format("https://{0}:{1}", _configuration.Address, _configuration.Port)); IgnoreBadCertificates(); }
/// <summary> /// Constructor /// /// Current state is initialized to <see cref="Dynatrace.OpenKit.Core.Communication.BeaconSendingInitState"/>. /// </summary> internal BeaconSendingContext( ILogger logger, IHttpClientConfiguration httpClientConfiguration, IHttpClientProvider httpClientProvider, ITimingProvider timingProvider, IInterruptibleThreadSuspender threadSuspender ) : this(logger, httpClientConfiguration, httpClientProvider, timingProvider, threadSuspender, new BeaconSendingInitState()) { }
internal BeaconSender( ILogger logger, IHttpClientConfiguration httpClientConfiguration, IHttpClientProvider clientProvider, ITimingProvider timingProvider, IInterruptibleThreadSuspender threadSuspender) { this.logger = logger; context = new BeaconSendingContext(logger, httpClientConfiguration, clientProvider, timingProvider, threadSuspender); }
public HttpClientWebClient(ILogger logger, IHttpClientConfiguration configuration, IInterruptibleThreadSuspender threadSuspender) : base(logger, configuration, threadSuspender) { if (!_remoteCertificateValidationCallbackInitialized) { ServicePointManager.ServerCertificateValidationCallback += configuration.SslTrustManager?.ServerCertificateValidationCallback; _remoteCertificateValidationCallbackInitialized = true; } }
public void HandleStatusResponseUpdatesHttpClientConfig() { mockHttpClientConfig.BaseUrl.Returns("https://localhost:9999/1"); mockHttpClientConfig.ApplicationId.Returns("some cryptic appId"); mockHttpClientConfig.ServerId.Returns(42); mockHttpClientConfig.SslTrustManager.Returns(Substitute.For <ISSLTrustManager>()); const int serverId = 73; var responseAttributes = ResponseAttributes.WithUndefinedDefaults().WithServerId(serverId).Build(); var response = StatusResponse.CreateSuccessResponse( mockLogger, responseAttributes, StatusResponse.HttpOk, new Dictionary <string, List <string> >() ); var target = Substitute.ForPartsOf <BeaconSendingContext>( mockLogger, mockHttpClientConfig, mockHttpClientProvider, mockTimingProvider, mockThreadSuspender ); Assert.That(mockHttpClientConfig.ReceivedCalls(), Is.Empty); // when target.HandleStatusResponse(response); // then target.Received(1).CreateHttpClientConfigurationWith(serverId); _ = mockHttpClientConfig.Received(2).ServerId; _ = mockHttpClientConfig.Received(1).BaseUrl; _ = mockHttpClientConfig.Received(1).ApplicationId; _ = mockHttpClientConfig.Received(1).SslTrustManager; // and when IHttpClientConfiguration configCapture = null; mockHttpClientProvider.CreateClient(Arg.Do <IHttpClientConfiguration>(c => configCapture = c)); target.GetHttpClient(); // then Assert.That(configCapture, Is.Not.Null); mockHttpClientProvider.Received(1).CreateClient(configCapture); Assert.That(configCapture, Is.Not.SameAs(mockHttpClientConfig)); Assert.That(configCapture.ServerId, Is.EqualTo(serverId)); Assert.That(configCapture.BaseUrl, Is.EqualTo(mockHttpClientConfig.BaseUrl)); Assert.That(configCapture.ApplicationId, Is.EqualTo(mockHttpClientConfig.ApplicationId)); Assert.That(configCapture.SslTrustManager, Is.SameAs(mockHttpClientConfig.SslTrustManager)); }
public OAuthUtils(ISettings settings, IDevice device, IUserInteractionService userInteraction, IAccountService account, IHttpClientConfiguration httpClientConfiguration, IMvxWebBrowserTask browser, IServiceApi serviceApi) { this.settings = settings; this.device = device; this.userInteraction = userInteraction; this.account = account; this.httpClientConfiguration = httpClientConfiguration; this.State = this.settings.GetValueOrDefault(StateKey, Guid.NewGuid().ToString()); this.browser = browser; this.serviceApi = serviceApi; this.oAuthClient = serviceApi.OAuthClient; this.oAuthSecret = serviceApi.OAuthSecret; }
public static OpenIdClient Create(RequestTimeouts requestTimeouts, IHttpClientConfiguration clientConfiguration, ILog log) { var http = new HttpRequestFactory( clientConfiguration, requestTimeouts, null, HandleOpenIdErrorResponse, null, Serializer, log ); return(new OpenIdClient(http)); }
public HttpClientDataSinkBase( IHttpClientConfiguration config, IAuthenticationHeaderGenerator authenticationHeaderGenerator, ILogger <HttpClientDataSinkBase> logger = null) { Contract.Requires(config != null); Contract.Requires(authenticationHeaderGenerator != null); Contract.Ensures(this.Config != null); Contract.Ensures(this.AuthenticationHeaderGenerator != null); this.Config = config; this.AuthenticationHeaderGenerator = authenticationHeaderGenerator; this.Logger = logger; }
public HttpRequestFactory( IHttpClientConfiguration configuration, RequestTimeouts requestTimeouts, Func <Request, TimeSpan, Task <Request> >?requestTransformAsync, Func <IHttpResponse, ValueTask <bool> >?errorResponseHandler, FailoverAsync?failover, IJsonSerializer serializer, ILog log) { this.requestTimeouts = requestTimeouts ?? throw new ArgumentNullException(nameof(requestTimeouts)); this.requestTransformAsync = requestTransformAsync; this.errorResponseHandler = errorResponseHandler; this.failover = failover; this.serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); clusterClient = ClusterClientFactory.CreateClusterClient(configuration, log); }
private static HttpRequestFactory CreateHttp( IHttpClientConfiguration configuration, ILog log, Func <Request, TimeSpan, Task <Request> >?requestTransformAsync = null, Func <IHttpResponse, ValueTask <bool> >?errorResponseHandler = null, FailoverAsync?failover = null) { return(new( configuration, new RequestTimeouts(), requestTransformAsync, errorResponseHandler, failover, new SystemTextJsonSerializerFactory().CreateSerializer(), log )); }
public IValidationResult Validate(HttpContent content, IHttpClientConfiguration configuration) { IValidationErrorCollection errors = new ValidationErrorCollection(); var mediaType = configuration.ValidHeaders.ContentType.MediaType; if (!content.Headers.Contains(mediaType)) { //#refactor message into resource file var validationError = new InvalidContentTypeError($"Configured media type {mediaType} is missing in headers."); errors.Add(validationError); } if (errors.Any()) { return(new ValidationFailed(errors)); } return(new ValidationOk()); }
public ReadOnlyConfig(ICouchbaseClientConfiguration original) { this.bucket = original.Bucket; this.bucketPassword = original.BucketPassword; this.username = original.Username; this.password = original.Password; this.urls = original.Urls.ToArray(); this.retryCount = original.RetryCount; this.retryTimeout = original.RetryTimeout; this.observeTimeout = original.ObserveTimeout; this.httpRequestTimeout = original.HttpRequestTimeout; this.spc = new SPC(original.SocketPool); this.hbm = new HBM(original.HeartbeatMonitor); this.hcc = new HCC(original.HttpClient); this.original = original; }
internal BeaconSendingContext( ILogger logger, IHttpClientConfiguration httpClientConfiguration, IHttpClientProvider httpClientProvider, ITimingProvider timingProvider, IInterruptibleThreadSuspender threadSuspender, AbstractBeaconSendingState initialState ) { this.logger = logger; this.httpClientConfiguration = httpClientConfiguration; serverConfiguration = ServerConfiguration.Default; HttpClientProvider = httpClientProvider; this.timingProvider = timingProvider; this.threadSuspender = threadSuspender; lastResponseAttributes = ResponseAttributes.WithUndefinedDefaults().Build(); CurrentState = initialState; }
private HttpRequestFactory CreateHttp( IHttpClientConfiguration clientConfiguration, RequestTimeouts requestTimeouts, IAuthenticator authenticator, IJsonSerializer jsonSerializer, ILog log) { FailoverAsync?unauthorizedFailover = EnableUnauthorizedFailover ? (response, attempt) => AuthorizationErrorsFailover(requestTimeouts, authenticator, response, attempt) : null; return(new HttpRequestFactory( clientConfiguration, requestTimeouts, (request, span) => AuthenticateRequestAsync(authenticator, request, span), HandleApiErrors, unauthorizedFailover, jsonSerializer, log ));
public HCC(IHttpClientConfiguration original) { this.initializeConnection = original.InitializeConnection; this.timeout = original.Timeout; }
public ReadOnlyConfig(ICouchbaseClientConfiguration original) { this.bucket = original.Bucket; this.bucketPassword = original.BucketPassword; this.username = original.Username; this.password = original.Password; this.urls = original.Urls.ToArray(); this.retryCount = original.RetryCount; this.retryTimeout = original.RetryTimeout; this.observeTimeout = original.ObserveTimeout; this.httpRequestTimeout = original.HttpRequestTimeout; this.spc = new SPC(original.SocketPool); this.hbm = new HBM(original.HeartbeatMonitor); this.hcc = new HCC(original.HttpClient); this.original = original; _vBucketRetryCount = original.VBucketRetryCount; }