mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Oops I forgot to commit a file
This commit is contained in:
22
Robust.Shared/Utility/HttpClientUserAgent.cs
Normal file
22
Robust.Shared/Utility/HttpClientUserAgent.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace Robust.Shared.Utility;
|
||||
|
||||
internal static class HttpClientUserAgent
|
||||
{
|
||||
private const string ProductName = "RobustToolbox";
|
||||
|
||||
/// <summary>
|
||||
/// Add a Robust-specific user agent to the default request headers of the given <see cref="HttpClient"/>.
|
||||
/// </summary>
|
||||
public static void AddUserAgent(HttpClient client)
|
||||
{
|
||||
var assemblyName = typeof(HttpClientUserAgent).Assembly.GetName();
|
||||
if (assemblyName.Version is { } version)
|
||||
{
|
||||
client.DefaultRequestHeaders.UserAgent.Add(
|
||||
new ProductInfoHeaderValue(ProductName, version.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user