mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-16 05:53:03 +03:00
fix SA1005
This commit is contained in:
@@ -46,7 +46,7 @@ namespace Rssdp.Infrastructure
|
||||
{
|
||||
var lines = data.Split(LineTerminators, StringSplitOptions.None);
|
||||
|
||||
//First line is the 'request' line containing http protocol details like method, uri, http version etc.
|
||||
// First line is the 'request' line containing http protocol details like method, uri, http version etc.
|
||||
ParseStatusLine(lines[0], message);
|
||||
|
||||
ParseHeaders(headers, retVal.Headers, lines);
|
||||
@@ -93,16 +93,16 @@ namespace Rssdp.Infrastructure
|
||||
/// <param name="contentHeaders">A reference to a <see cref="System.Net.Http.Headers.HttpHeaders"/> collection for the message content, to which the parsed header will be added.</param>
|
||||
private void ParseHeader(string line, System.Net.Http.Headers.HttpHeaders headers, System.Net.Http.Headers.HttpHeaders contentHeaders)
|
||||
{
|
||||
//Header format is
|
||||
//name: value
|
||||
// Header format is
|
||||
// name: value
|
||||
var headerKeySeparatorIndex = line.IndexOf(":", StringComparison.OrdinalIgnoreCase);
|
||||
var headerName = line.Substring(0, headerKeySeparatorIndex).Trim();
|
||||
var headerValue = line.Substring(headerKeySeparatorIndex + 1).Trim();
|
||||
|
||||
//Not sure how to determine where request headers and and content headers begin,
|
||||
//at least not without a known set of headers (general headers first the content headers)
|
||||
//which seems like a bad way of doing it. So we'll assume if it's a known content header put it there
|
||||
//else use request headers.
|
||||
// Not sure how to determine where request headers and and content headers begin,
|
||||
// at least not without a known set of headers (general headers first the content headers)
|
||||
// which seems like a bad way of doing it. So we'll assume if it's a known content header put it there
|
||||
// else use request headers.
|
||||
|
||||
var values = ParseValues(headerValue);
|
||||
var headersToAddTo = IsContentHeader(headerName) ? contentHeaders : headers;
|
||||
@@ -115,13 +115,13 @@ namespace Rssdp.Infrastructure
|
||||
|
||||
private int ParseHeaders(System.Net.Http.Headers.HttpHeaders headers, System.Net.Http.Headers.HttpHeaders contentHeaders, string[] lines)
|
||||
{
|
||||
//Blank line separates headers from content, so read headers until we find blank line.
|
||||
// Blank line separates headers from content, so read headers until we find blank line.
|
||||
int lineIndex = 1;
|
||||
string line = null, nextLine = null;
|
||||
while (lineIndex + 1 < lines.Length && !String.IsNullOrEmpty((line = lines[lineIndex++])))
|
||||
{
|
||||
//If the following line starts with space or tab (or any whitespace), it is really part of this header but split for human readability.
|
||||
//Combine these lines into a single comma separated style header for easier parsing.
|
||||
// If the following line starts with space or tab (or any whitespace), it is really part of this header but split for human readability.
|
||||
// Combine these lines into a single comma separated style header for easier parsing.
|
||||
while (lineIndex < lines.Length && !String.IsNullOrEmpty((nextLine = lines[lineIndex])))
|
||||
{
|
||||
if (nextLine.Length > 0 && Char.IsWhiteSpace(nextLine[0]))
|
||||
|
||||
@@ -485,9 +485,9 @@ namespace Rssdp.Infrastructure
|
||||
|
||||
private void OnRequestReceived(HttpRequestMessage data, IPEndPoint remoteEndPoint, IPAddress receivedOnLocalIpAddress)
|
||||
{
|
||||
//SSDP specification says only * is currently used but other uri's might
|
||||
//be implemented in the future and should be ignored unless understood.
|
||||
//Section 4.2 - http://tools.ietf.org/html/draft-cai-ssdp-v1-03#page-11
|
||||
// SSDP specification says only * is currently used but other uri's might
|
||||
// be implemented in the future and should be ignored unless understood.
|
||||
// Section 4.2 - http://tools.ietf.org/html/draft-cai-ssdp-v1-03#page-11
|
||||
if (data.RequestUri.ToString() != "*")
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -337,7 +337,7 @@ namespace Rssdp.Infrastructure
|
||||
|
||||
values["HOST"] = "239.255.255.250:1900";
|
||||
values["USER-AGENT"] = "UPnP/1.0 DLNADOC/1.50 Platinum/1.0.4.2";
|
||||
//values["X-EMBY-SERVERID"] = _appHost.SystemId;
|
||||
// values["X-EMBY-SERVERID"] = _appHost.SystemId;
|
||||
|
||||
values["MAN"] = "\"ssdp:discover\"";
|
||||
|
||||
|
||||
@@ -205,25 +205,25 @@ namespace Rssdp.Infrastructure
|
||||
return;
|
||||
}
|
||||
|
||||
//WriteTrace(String.Format("Search Request Received From {0}, Target = {1}", remoteEndPoint.ToString(), searchTarget));
|
||||
// WriteTrace(String.Format("Search Request Received From {0}, Target = {1}", remoteEndPoint.ToString(), searchTarget));
|
||||
|
||||
if (IsDuplicateSearchRequest(searchTarget, remoteEndPoint))
|
||||
{
|
||||
//WriteTrace("Search Request is Duplicate, ignoring.");
|
||||
// WriteTrace("Search Request is Duplicate, ignoring.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Wait on random interval up to MX, as per SSDP spec.
|
||||
//Also, as per UPnP 1.1/SSDP spec ignore missing/bank MX header. If over 120, assume random value between 0 and 120.
|
||||
//Using 16 as minimum as that's often the minimum system clock frequency anyway.
|
||||
// Wait on random interval up to MX, as per SSDP spec.
|
||||
// Also, as per UPnP 1.1/SSDP spec ignore missing/bank MX header. If over 120, assume random value between 0 and 120.
|
||||
// Using 16 as minimum as that's often the minimum system clock frequency anyway.
|
||||
int maxWaitInterval = 0;
|
||||
if (String.IsNullOrEmpty(mx))
|
||||
{
|
||||
//Windows Explorer is poorly behaved and doesn't supply an MX header value.
|
||||
//if (this.SupportPnpRootDevice)
|
||||
// Windows Explorer is poorly behaved and doesn't supply an MX header value.
|
||||
// if (this.SupportPnpRootDevice)
|
||||
mx = "1";
|
||||
//else
|
||||
//return;
|
||||
// else
|
||||
// return;
|
||||
}
|
||||
|
||||
if (!Int32.TryParse(mx, out maxWaitInterval) || maxWaitInterval <= 0) return;
|
||||
@@ -231,10 +231,10 @@ namespace Rssdp.Infrastructure
|
||||
if (maxWaitInterval > 120)
|
||||
maxWaitInterval = _Random.Next(0, 120);
|
||||
|
||||
//Do not block synchronously as that may tie up a threadpool thread for several seconds.
|
||||
// Do not block synchronously as that may tie up a threadpool thread for several seconds.
|
||||
Task.Delay(_Random.Next(16, (maxWaitInterval * 1000))).ContinueWith((parentTask) =>
|
||||
{
|
||||
//Copying devices to local array here to avoid threading issues/enumerator exceptions.
|
||||
// Copying devices to local array here to avoid threading issues/enumerator exceptions.
|
||||
IEnumerable<SsdpDevice> devices = null;
|
||||
lock (_Devices)
|
||||
{
|
||||
@@ -251,7 +251,7 @@ namespace Rssdp.Infrastructure
|
||||
if (devices != null)
|
||||
{
|
||||
var deviceList = devices.ToList();
|
||||
//WriteTrace(String.Format("Sending {0} search responses", deviceList.Count));
|
||||
// WriteTrace(String.Format("Sending {0} search responses", deviceList.Count));
|
||||
|
||||
foreach (var device in deviceList)
|
||||
{
|
||||
@@ -264,7 +264,7 @@ namespace Rssdp.Infrastructure
|
||||
}
|
||||
else
|
||||
{
|
||||
//WriteTrace(String.Format("Sending 0 search responses."));
|
||||
// WriteTrace(String.Format("Sending 0 search responses."));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -308,7 +308,7 @@ namespace Rssdp.Infrastructure
|
||||
{
|
||||
var rootDevice = device.ToRootDevice();
|
||||
|
||||
//var additionalheaders = FormatCustomHeadersForResponse(device);
|
||||
// var additionalheaders = FormatCustomHeadersForResponse(device);
|
||||
|
||||
const string header = "HTTP/1.1 200 OK";
|
||||
|
||||
@@ -338,7 +338,7 @@ namespace Rssdp.Infrastructure
|
||||
|
||||
}
|
||||
|
||||
//WriteTrace(String.Format("Sent search response to " + endPoint.ToString()), device);
|
||||
// WriteTrace(String.Format("Sent search response to " + endPoint.ToString()), device);
|
||||
}
|
||||
|
||||
private bool IsDuplicateSearchRequest(string searchTarget, IPEndPoint endPoint)
|
||||
@@ -384,7 +384,7 @@ namespace Rssdp.Infrastructure
|
||||
{
|
||||
if (IsDisposed) return;
|
||||
|
||||
//WriteTrace("Begin Sending Alive Notifications For All Devices");
|
||||
// WriteTrace("Begin Sending Alive Notifications For All Devices");
|
||||
|
||||
SsdpRootDevice[] devices;
|
||||
lock (_Devices)
|
||||
@@ -399,7 +399,7 @@ namespace Rssdp.Infrastructure
|
||||
SendAliveNotifications(device, true, CancellationToken.None);
|
||||
}
|
||||
|
||||
//WriteTrace("Completed Sending Alive Notifications For All Devices");
|
||||
// WriteTrace("Completed Sending Alive Notifications For All Devices");
|
||||
}
|
||||
catch (ObjectDisposedException ex)
|
||||
{
|
||||
@@ -448,7 +448,7 @@ namespace Rssdp.Infrastructure
|
||||
|
||||
_CommsServer.SendMulticastMessage(message, _sendOnlyMatchedHost ? rootDevice.Address : null, cancellationToken);
|
||||
|
||||
//WriteTrace(String.Format("Sent alive notification"), device);
|
||||
// WriteTrace(String.Format("Sent alive notification"), device);
|
||||
}
|
||||
|
||||
private Task SendByeByeNotifications(SsdpDevice device, bool isRoot, CancellationToken cancellationToken)
|
||||
@@ -533,7 +533,7 @@ namespace Rssdp.Infrastructure
|
||||
{
|
||||
LogFunction(text);
|
||||
}
|
||||
//System.Diagnostics.Debug.WriteLine(text, "SSDP Publisher");
|
||||
// System.Diagnostics.Debug.WriteLine(text, "SSDP Publisher");
|
||||
}
|
||||
|
||||
private void WriteTrace(string text, SsdpDevice device)
|
||||
@@ -551,13 +551,13 @@ namespace Rssdp.Infrastructure
|
||||
|
||||
if (string.Equals(e.Message.Method.Method, SsdpConstants.MSearchMethod, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
//According to SSDP/UPnP spec, ignore message if missing these headers.
|
||||
// According to SSDP/UPnP spec, ignore message if missing these headers.
|
||||
// Edit: But some devices do it anyway
|
||||
//if (!e.Message.Headers.Contains("MX"))
|
||||
// if (!e.Message.Headers.Contains("MX"))
|
||||
// WriteTrace("Ignoring search request - missing MX header.");
|
||||
//else if (!e.Message.Headers.Contains("MAN"))
|
||||
// else if (!e.Message.Headers.Contains("MAN"))
|
||||
// WriteTrace("Ignoring search request - missing MAN header.");
|
||||
//else
|
||||
// else
|
||||
ProcessSearchRequest(GetFirstHeaderValue(e.Message.Headers, "MX"), GetFirstHeaderValue(e.Message.Headers, "ST"), e.ReceivedFrom, e.LocalIpAddress, CancellationToken.None);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user