@@ -14,6 +14,7 @@ namespace SteamWebAPI2
1414 internal class SteamStoreRequest
1515 {
1616 private string steamStoreApiBaseUrl ;
17+ private readonly HttpClient httpClient ;
1718
1819 /// <summary>
1920 /// Constructs a Steam Store Web API request
@@ -29,6 +30,17 @@ public SteamStoreRequest(string steamStoreApiBaseUrl)
2930 this . steamStoreApiBaseUrl = steamStoreApiBaseUrl ;
3031 }
3132
33+ public SteamStoreRequest ( string steamStoreApiBaseUrl , HttpClient httpClient )
34+ {
35+ if ( String . IsNullOrEmpty ( steamStoreApiBaseUrl ) )
36+ {
37+ throw new ArgumentNullException ( "steamStoreApiBaseUrl" ) ;
38+ }
39+
40+ this . steamStoreApiBaseUrl = steamStoreApiBaseUrl ;
41+ this . httpClient = httpClient ;
42+ }
43+
3244 /// <summary>
3345 /// Sends a request to a Steam Store Web API endpoint
3446 /// </summary>
@@ -71,10 +83,10 @@ public async Task<T> SendStoreRequestAsync<T>(string endpointName, IList<SteamWe
7183 /// </summary>
7284 /// <param name="command">Command (method endpoint) to send to an interface</param>
7385 /// <returns>HTTP response as a string without tabs and newlines</returns>
74- private static async Task < string > GetHttpStringResponseAsync ( string command )
86+ private async Task < string > GetHttpStringResponseAsync ( string command )
7587 {
76- HttpClient httpClient = new HttpClient ( ) ;
77- string response = await httpClient . GetStringAsync ( command ) ;
88+ HttpClient client = httpClient ?? new HttpClient ( ) ;
89+ string response = await client . GetStringAsync ( command ) ;
7890 response = response . Replace ( "\n " , "" ) ;
7991 response = response . Replace ( "\t " , "" ) ;
8092 return response ;
0 commit comments