aboutsummaryrefslogtreecommitdiff
path: root/Emby.Common.Implementations/BaseApplicationHost.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-02-09 19:39:51 -0500
committerGitHub <noreply@github.com>2017-02-09 19:39:51 -0500
commitf1c7b860819abdec1a92068a1494a806a76954d9 (patch)
treefc9ac5c0adeef0574e69ce0d1c98816b72ee22b0 /Emby.Common.Implementations/BaseApplicationHost.cs
parent926b7fd42d0738f3afc39d6ab353535bb9fb948c (diff)
parent57637565ca72e4126dd29e669c7c8bf13af556d4 (diff)
Merge pull request #2458 from MediaBrowser/beta
Beta
Diffstat (limited to 'Emby.Common.Implementations/BaseApplicationHost.cs')
-rw-r--r--Emby.Common.Implementations/BaseApplicationHost.cs26
1 files changed, 25 insertions, 1 deletions
diff --git a/Emby.Common.Implementations/BaseApplicationHost.cs b/Emby.Common.Implementations/BaseApplicationHost.cs
index 87b97863bd..147a43fa18 100644
--- a/Emby.Common.Implementations/BaseApplicationHost.cs
+++ b/Emby.Common.Implementations/BaseApplicationHost.cs
@@ -527,7 +527,7 @@ return null;
RegisterSingleInstance(FileSystemManager);
- HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, LogManager.GetLogger("HttpClient"), FileSystemManager, MemoryStreamFactory);
+ HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, LogManager.GetLogger("HttpClient"), FileSystemManager, MemoryStreamFactory, GetDefaultUserAgent);
RegisterSingleInstance(HttpClient);
RegisterSingleInstance(NetworkManager);
@@ -549,6 +549,30 @@ return null;
return Task.FromResult(true);
}
+ private string GetDefaultUserAgent()
+ {
+ var name = FormatAttribute(Name);
+
+ return name + "/" + ApplicationVersion.ToString();
+ }
+
+ private string FormatAttribute(string str)
+ {
+ var arr = str.ToCharArray();
+
+ arr = Array.FindAll<char>(arr, (c => (char.IsLetterOrDigit(c)
+ || char.IsWhiteSpace(c))));
+
+ var result = new string(arr);
+
+ if (string.IsNullOrWhiteSpace(result))
+ {
+ result = "Emby";
+ }
+
+ return result;
+ }
+
/// <summary>
/// Gets a list of types within an assembly
/// This will handle situations that would normally throw an exception - such as a type within the assembly that depends on some other non-existant reference