mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-09 15:20:34 +02:00
fix dlna header parsing
This commit is contained in:
parent
83ab940f73
commit
fe9d58687c
|
@ -210,6 +210,10 @@ namespace MediaBrowser.Dlna
|
||||||
throw new ArgumentNullException("headers");
|
throw new ArgumentNullException("headers");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//_logger.Debug("GetProfile. Headers: " + _jsonSerializer.SerializeToString(headers));
|
||||||
|
// Convert to case insensitive
|
||||||
|
headers = new Dictionary<string, string>(headers, StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
var profile = GetProfiles().FirstOrDefault(i => i.Identification != null && IsMatch(headers, i.Identification));
|
var profile = GetProfiles().FirstOrDefault(i => i.Identification != null && IsMatch(headers, i.Identification));
|
||||||
|
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
|
@ -221,7 +225,7 @@ namespace MediaBrowser.Dlna
|
||||||
string userAgent = null;
|
string userAgent = null;
|
||||||
headers.TryGetValue("User-Agent", out userAgent);
|
headers.TryGetValue("User-Agent", out userAgent);
|
||||||
|
|
||||||
var msg = "No matching device profile found. The default will be used. ";
|
var msg = "No matching device profile via headers found. The default will be used. ";
|
||||||
if (!string.IsNullOrEmpty(userAgent))
|
if (!string.IsNullOrEmpty(userAgent))
|
||||||
{
|
{
|
||||||
msg += "User-agent: " + userAgent + ". ";
|
msg += "User-agent: " + userAgent + ". ";
|
||||||
|
@ -249,7 +253,9 @@ namespace MediaBrowser.Dlna
|
||||||
case HeaderMatchType.Equals:
|
case HeaderMatchType.Equals:
|
||||||
return string.Equals(value, header.Value, StringComparison.OrdinalIgnoreCase);
|
return string.Equals(value, header.Value, StringComparison.OrdinalIgnoreCase);
|
||||||
case HeaderMatchType.Substring:
|
case HeaderMatchType.Substring:
|
||||||
return value.IndexOf(header.Value, StringComparison.OrdinalIgnoreCase) != -1;
|
var isMatch = value.IndexOf(header.Value, StringComparison.OrdinalIgnoreCase) != -1;
|
||||||
|
//_logger.Debug("IsMatch-Substring value: {0} testValue: {1} isMatch: {2}", value, header.Value, isMatch);
|
||||||
|
return isMatch;
|
||||||
case HeaderMatchType.Regex:
|
case HeaderMatchType.Regex:
|
||||||
// Reports of IgnoreCase not working on linux so try it a couple different ways.
|
// Reports of IgnoreCase not working on linux so try it a couple different ways.
|
||||||
return Regex.IsMatch(value, header.Value, RegexOptions.IgnoreCase) || Regex.IsMatch(value.ToUpper(), header.Value.ToUpper(), RegexOptions.IgnoreCase);
|
return Regex.IsMatch(value, header.Value, RegexOptions.IgnoreCase) || Regex.IsMatch(value.ToUpper(), header.Value.ToUpper(), RegexOptions.IgnoreCase);
|
||||||
|
|
|
@ -177,7 +177,7 @@ namespace MediaBrowser.Dlna.Ssdp
|
||||||
{
|
{
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
await Task.Delay(500).ConfigureAwait(false);
|
await Task.Delay(200).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var dgram = new Datagram(endpoint, localAddress, _logger, msg, isBroadcast, enableDebugLogging);
|
var dgram = new Datagram(endpoint, localAddress, _logger, msg, isBroadcast, enableDebugLogging);
|
||||||
|
|
Loading…
Reference in a new issue