internal async Task <WebProxyResponse> GetWebProxyResponse(HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken) { using (var httpClient = new HttpClient()) using (var response = await httpClient.SendAsync(httpRequestMessage, cancellationToken)) { var webProxyResponse = new WebProxyResponse { Content = await response.Content.ReadAsStringAsync(), IsSuccessStatusCode = response.IsSuccessStatusCode, ReasonPhrase = response.ReasonPhrase, StatusCode = response.StatusCode }; return(webProxyResponse); } }
internal async Task <WebProxyResponse <T> > GetWebProxyResponse <T>(HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken) { using (var httpClient = new HttpClient()) using (var response = await httpClient.SendAsync(httpRequestMessage, cancellationToken)) { var webProxyResponse = new WebProxyResponse <T> { Content = await response.Content.ReadAsStringAsync(), IsSuccessStatusCode = response.IsSuccessStatusCode, ReasonPhrase = response.ReasonPhrase, StatusCode = response.StatusCode }; if (response.IsSuccessStatusCode) { webProxyResponse.Data = JsonConvert.DeserializeObject <T>(webProxyResponse.Content); } return(webProxyResponse); } }