Example #1
0
 public HttpClientRequest(Uri uri)
 {
     RequestUri = uri;
     Provider   = DependencyInjector.Get <IHttpClientProvider> ();
     Handler    = Provider.Create();
     Client     = Handler.CreateHttpClient();
 }
Example #2
0
        /*
         * It's good practice to keep these requests asynchronous. .NET uses * async/await just like ES2017.
         */
        public async Task <string> GetData(string baseUrl)
        {
            //The 'using' will help to prevent memory leaks
            //Create a new instance of HttpClient
            IHttpClientHandler client = _httpClient;

            //Setting up the response...
            using (HttpResponseMessage res = await client.GetAsync(baseUrl))
                try
                {
                    Console.WriteLine("Starting here before expection");
                    using (HttpContent content = res.Content)
                    {
                        string data = await content.ReadAsStringAsync();

                        if (data != null)
                        {
                            Console.WriteLine(data);
                            return(data);
                        }
                        else
                        {
                            Console.WriteLine("no data");
                            return("err no data");
                        }
                    }
                }
                catch (Exception e)
                {
                    return("err no content");
                }
        }
Example #3
0
 public AuthorService(IUnitOfWork <AlejandriaContext> uoW,
                      IOptions <AlejandriaOptions> alejandriaOptions,
                      IOptions <CircuitBreakerOptions> circuitBreakerOptions,
                      IHttpClientHandler httpClientHandler) : base(uoW)
 {
     _authorRepository = uoW.Repository <IAuthorRepository>();
     _bookRepository   = uoW.Repository <IBookRepository>();
     InitializeAlejandriaOptions(alejandriaOptions);
     InitializeCircuitBreaker(httpClientHandler, circuitBreakerOptions);
 }
Example #4
0
        public HttpClientRequest(
            InstrumentationOperation operation,
            HttpClientHandler handler,
            Uri requestUri)
        {
            Operation  = operation;
            Parent     = handler;
            RequestUri = requestUri;

            Provider = DependencyInjector.Get <IHttpClientProvider> ();
            Handler  = Provider.Create();
            Client   = Handler.CreateHttpClient();
        }
Example #5
0
        public HttpClientRequest(
            InstrumentationOperation operation,
            HttpClientHandler handler,
            HttpClientRequest primaryRequest,
            Uri requestUri)
        {
            Operation  = operation;
            Parent     = handler;
            RequestUri = requestUri;

            Handler = primaryRequest.Handler;
            Client  = primaryRequest.Client;
        }
        public PopulatorRunner(
            IRepository repository,
            IRedisStoreFactory redisStoreFactory,
            IHttpClientHandler httpClient,
            IConfiguration configuration,
            ILogger <PopulatorRunner> logger)
        {
            _repository        = repository;
            _redisStoreFactory = redisStoreFactory;
            _httpClient        = httpClient;
            _logger            = logger;

            _databaseBatchSize     = configuration.GetValue <int?>("DatabaseBatchSize") ?? 1000;
            _collectorBatchSize    = configuration.GetValue <int?>("CollectorBatchSize") ?? 100;
            _maxErrorTimeInSeconds = configuration.GetValue <int?>("MaxErrorTimeInSeconds") ?? 60;

            _validStatusCodes         = configuration.GetSection("ValidStatusCodes").Get <int[]>();
            _validStatusCodesToDelete = configuration.GetSection("ValidStatusCodesToDelete").Get <int[]>();
            _headersToStore           = configuration.GetSection("HeadersToStore").Get <string[]>();
            _apiBaseAddress           = configuration["ApiBaseAddress"];
        }
 public OpenWeatherService(IHttpClientHandler httpClient)
 {
     _httpClient = httpClient;
 }
Example #8
0
 public BlockExplorerProvider(IHttpClientHandler httpClient)
     : base(httpClient)
 {
 }
Example #9
0
 public Requests(IHttpClientHandler httpClient)
 {
     _httpClient = httpClient;
 }
Example #10
0
 public ExtensionTestRunner(IHttpClientHandler extension)
 {
     this.extension = extension;
 }
Example #11
0
 public SmaxHcmHandler(IHttpClientHandler httpClientHandler, IOptions <SmaxHcmOptions> smaxHcmOptions)
 {
     HttpClientHandler = httpClientHandler;
     SmaxHcmOptions    = smaxHcmOptions?.Value ?? throw new ArgumentException("No SmaxHcm options provided");
 }
 public void SetHandler(IHttpClientHandler handler)
 {
     this.Handler = handler;
 }
 public GoogleController(ILogger logger, IHttpClientHandler httpHandler, IConfiguration config)
 {
     _logger      = logger;
     _httpHandler = httpHandler;
     _config      = config;
 }
		public ExtensionTestRunner (IHttpClientHandler extension)
		{
			this.extension = extension;
		}
Example #15
0
 public MeterService(IHttpClientHandler httpClientHandler)
 {
     this.httpClientHandler = httpClientHandler;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="StarshipDataService" /> class.
 /// </summary>
 /// <param name="httpClientHandler">The HTTP client handler.</param>
 /// <param name="appConfigurationManager">The application configuration manager.</param>
 public StarshipDataService(IHttpClientHandler httpClientHandler, IAppConfigurationManager appConfigurationManager)
 {
     _appConfigurationManager = appConfigurationManager;
     _httpClientHandler       = httpClientHandler;
 }
Example #17
0
 public Notifier(ILogger logger, IHttpClientHandler httpClient, string slackConnectionString)
 {
     _logger     = logger;
     _httpClient = httpClient;
     _uri        = new Uri(slackConnectionString);
 }
 public YandexCustomSeacher(string subscriptionKey, string userName, IHttpClientHandler client)
 {
     SubscriptionKey = subscriptionKey;
     UserName        = userName;
     _client         = client;
 }
 public CyberArkHandler(IHttpClientHandler httpClientHandler, IOptions <CyberArkOptions> cyberArkOptions)
 {
     HttpClientHandler = httpClientHandler;
     CyberArkOptions   = cyberArkOptions?.Value ?? throw new ArgumentException("No CyberArk options provided");
 }
Example #20
0
 public BaseHttpProvider(IHttpClientHandler httpClient)
 {
     _httpClient = httpClient;
 }
Example #21
0
 private void InitializeCircuitBreaker(IHttpClientHandler httpClientHandler,
                                       IOptions <CircuitBreakerOptions> circuitBreakerOptions)
 {
     _httpClientHandler     = httpClientHandler;
     _circuitBreakerOptions = circuitBreakerOptions.Value;
 }
Example #22
0
 public SendFeedSyncHandler(IHttpClientHandler httpClientHandler)
 {
     _httpClientHandler = httpClientHandler;
 }
Example #23
0
 public KrakenAdapter(IHttpClientHandler httpClientHandler)
 {
     _httpClientHandler = httpClientHandler;
 }
 /// <summary>
 /// Converts provided <see cref="IHttpClientHandler"/> info to <see cref="HttpClientHandler"/>.
 /// </summary>
 /// <param name="abstraction">Instance of <see cref="IHttpClientHandler"/> to convert.</param>
 /// <returns>An instance of <see cref="HttpClientHandler"/>.</returns>
 public static HttpClientHandler ToImplementation(this IHttpClientHandler abstraction)
 {
     return(((IAbstraction <HttpClientHandler>)abstraction)?.UnsafeConvert());
 }
Example #25
0
 /// <summary>
 /// Ansible Tower handler constructor
 /// </summary>
 /// <param name="ansibleTowerInstance"></param>
 /// <param name="circuitBreakerHttpClient"></param>
 public AnsibleTowerHandler(IAnsibleTowerInstance ansibleTowerInstance, IHttpClientHandler httpClientHandler)
 {
     HttpClientHandler    = httpClientHandler;
     AnsibleTowerInstance = ansibleTowerInstance;
 }
Example #26
0
 public BingCustomSeacher(string subscriptionKey, string configID, IHttpClientHandler client)
 {
     SubscriptionKey = subscriptionKey;
     ConfigID        = configID;
     _client         = client;
 }
Example #27
0
 public StoryHttpClient(IHttpClientHandler httpClientHandler, IConfiguration configuration)
 {
     _httpClientHandler  = httpClientHandler;
     this._configuration = configuration;
 }
 public GlobalHashRateProvider(IHttpClientHandler httpClient)
     : base(httpClient)
 {
 }
Example #29
0
 public BitcoinWalletProvider(IHttpClientHandler httpClient)
     : base(httpClient)
 {
 }
Example #30
0
 public OwnerService(IHttpClientHandler httpHandler)
 {
     _httpHandler = httpHandler;
 }
 public MarketStackService(IHttpClientHandler httpClientHandler, IStreamHandler streamHandler)
 {
     _httpClientHandler = httpClientHandler;
     _streamHandler     = streamHandler;
 }