Skip to content

Instantly share code, notes, and snippets.

@alexandrebl
Created April 14, 2018 21:17
Show Gist options
  • Select an option

  • Save alexandrebl/ee6635cb8b6a895d90c554a7cd5fa7e4 to your computer and use it in GitHub Desktop.

Select an option

Save alexandrebl/ee6635cb8b6a895d90c554a7cd5fa7e4 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Net;
using System.Net.Http;
using BinanceCryptoCurrency.Domain;
using BinanceCryptoCurrency.Domain.Entity;
using Newtonsoft.Json;
namespace BinanceCryptoCurrency.Utility {
public class HttpUtilityTool {
private static readonly HttpClient HttpClient
= new HttpClient(new HttpClientHandler() { MaxConnectionsPerServer = 2000 });
private readonly ILogger _logger;
public HttpUtilityTool(ILogger logger) {
_logger = logger;
}
public HttpResponseMessage GetData(Uri uri) {
try {
HttpClient.BaseAddress = uri;
var httpRequestTask = HttpClient.GetAsync(uri);
var httpResponseMessage = httpRequestTask.Result;
return httpResponseMessage;
} catch (Exception ex) {
_logger.Write(ex);
return new HttpResponseMessage(HttpStatusCode.InternalServerError);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment