diff --git a/SteamKit2/SteamKit2/Steam/SteamClient/Configuration/SteamConfigurationBuilder.cs b/SteamKit2/SteamKit2/Steam/SteamClient/Configuration/SteamConfigurationBuilder.cs index 82b0ef9b2..cdf502a71 100644 --- a/SteamKit2/SteamKit2/Steam/SteamClient/Configuration/SteamConfigurationBuilder.cs +++ b/SteamKit2/SteamKit2/Steam/SteamClient/Configuration/SteamConfigurationBuilder.cs @@ -6,6 +6,7 @@ using System; using System.Net.Http; +using System.Net.Http.Headers; using SteamKit2.Discovery; namespace SteamKit2 @@ -107,6 +108,13 @@ public ISteamConfigurationBuilder WithWebAPIKey(string webApiKey) return this; } - static HttpClient DefaultHttpClientFactory() => new HttpClient(); + static HttpClient DefaultHttpClientFactory() + { + var client = new HttpClient(); + + var assemblyVersion = typeof(SteamConfiguration).Assembly.GetName().Version.ToString(fieldCount: 3); + client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("SteamKit", assemblyVersion)); + return client; + } } } diff --git a/SteamKit2/Tests/SteamConfigurationFacts.cs b/SteamKit2/Tests/SteamConfigurationFacts.cs index de5377aa4..38bbead69 100644 --- a/SteamKit2/Tests/SteamConfigurationFacts.cs +++ b/SteamKit2/Tests/SteamConfigurationFacts.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Net; using System.Net.Http; @@ -55,6 +56,9 @@ public void DefaultHttpClientFactory() { Assert.NotNull(client); Assert.IsType(client); + + var steamKitAssemblyVersion = typeof( SteamClient ).Assembly.GetName().Version; + Assert.Equal("SteamKit/" + steamKitAssemblyVersion.ToString(fieldCount: 3), client.DefaultRequestHeaders.UserAgent.ToString()); } }