-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInternalHttpClient.cs
More file actions
35 lines (31 loc) · 1.02 KB
/
InternalHttpClient.cs
File metadata and controls
35 lines (31 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace MakeWebRequest
{
/// <summary>
/// Internal client for sending Http Requests
/// </summary>
public class InternalHttpClient
{
private readonly HttpClient _httpClient;
/// <summary>
/// Internal client for sending Http Requests
/// </summary>
/// <param name="httpClient"></param>
public InternalHttpClient(HttpClient httpClient)
{
_httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
}
/// <summary>
/// Sends HttpRequestMessage and returns Content as string
/// </summary>
/// <param name="message">HttpRequestMessage to be sent</param>
/// <returns></returns>
public async Task<string> SendRequestAsync(HttpRequestMessage message)
{
var response = await _httpClient.SendAsync(message);
return await response.Content.ReadAsStringAsync();
}
}
}