mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-05 21:33:02 +02:00
P E R F O R M A N C E
This commit is contained in:
parent
0db0e8b944
commit
ac5c0866f3
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -13,21 +12,18 @@ namespace MediaBrowser.Common.Net
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UserAgentDelegatingHandler : DelegatingHandler
|
public class UserAgentDelegatingHandler : DelegatingHandler
|
||||||
{
|
{
|
||||||
|
private readonly ProductInfoHeaderValue[] _userAgentValues;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public UserAgentDelegatingHandler(IApplicationHost applicationHost)
|
public UserAgentDelegatingHandler(IApplicationHost applicationHost)
|
||||||
{
|
{
|
||||||
UserAgentValues = new List<ProductInfoHeaderValue>
|
_userAgentValues = new []
|
||||||
{
|
{
|
||||||
new ProductInfoHeaderValue(applicationHost.Name.Replace(' ', '-'), applicationHost.ApplicationVersionString),
|
new ProductInfoHeaderValue(applicationHost.Name.Replace(' ', '-'), applicationHost.ApplicationVersionString),
|
||||||
new ProductInfoHeaderValue($"({Environment.OSVersion}; {applicationHost.ApplicationUserAgentAddress})")
|
new ProductInfoHeaderValue($"({Environment.OSVersion}; {applicationHost.ApplicationUserAgentAddress})")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the user agent values.
|
|
||||||
/// </summary>
|
|
||||||
public List<ProductInfoHeaderValue> UserAgentValues { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send request message.
|
/// Send request message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -40,9 +36,9 @@ namespace MediaBrowser.Common.Net
|
||||||
{
|
{
|
||||||
if (request.Headers.UserAgent.Count == 0)
|
if (request.Headers.UserAgent.Count == 0)
|
||||||
{
|
{
|
||||||
foreach (var userAgentValue in UserAgentValues)
|
for (var i = 0; i < _userAgentValues.Length; i++)
|
||||||
{
|
{
|
||||||
request.Headers.UserAgent.Add(userAgentValue);
|
request.Headers.UserAgent.Add(_userAgentValues[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue