aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Emby.Dlna/Server/DescriptionXmlBuilder.cs16
-rw-r--r--Emby.Dlna/Service/BaseControlHandler.cs25
2 files changed, 24 insertions, 17 deletions
diff --git a/Emby.Dlna/Server/DescriptionXmlBuilder.cs b/Emby.Dlna/Server/DescriptionXmlBuilder.cs
index 1f429d0de..bca9e81cd 100644
--- a/Emby.Dlna/Server/DescriptionXmlBuilder.cs
+++ b/Emby.Dlna/Server/DescriptionXmlBuilder.cs
@@ -235,13 +235,13 @@ namespace Emby.Dlna.Server
.Append(SecurityElement.Escape(service.ServiceId ?? string.Empty))
.Append("</serviceId>");
builder.Append("<SCPDURL>")
- .Append(BuildUrl(service.ScpdUrl, true))
+ .Append(BuildUrl(service.ScpdUrl))
.Append("</SCPDURL>");
builder.Append("<controlURL>")
- .Append(BuildUrl(service.ControlUrl, true))
+ .Append(BuildUrl(service.ControlUrl))
.Append("</controlURL>");
builder.Append("<eventSubURL>")
- .Append(BuildUrl(service.EventSubUrl, true))
+ .Append(BuildUrl(service.EventSubUrl))
.Append("</eventSubURL>");
builder.Append("</service>");
@@ -250,13 +250,7 @@ namespace Emby.Dlna.Server
builder.Append("</serviceList>");
}
- /// <summary>
- /// Builds a valid url for inclusion in the xml.
- /// </summary>
- /// <param name="url">Url to include.</param>
- /// <param name="absoluteUrl">Optional. When set to true, the absolute url is always used.</param>
- /// <returns>The url to use for the element.</returns>
- private string BuildUrl(string url, bool absoluteUrl = false)
+ private string BuildUrl(string url)
{
if (string.IsNullOrEmpty(url))
{
@@ -267,7 +261,7 @@ namespace Emby.Dlna.Server
url = "/dlna/" + _serverUdn + "/" + url;
- if (EnableAbsoluteUrls || absoluteUrl)
+ if (EnableAbsoluteUrls)
{
url = _serverAddress.TrimEnd('/') + url;
}
diff --git a/Emby.Dlna/Service/BaseControlHandler.cs b/Emby.Dlna/Service/BaseControlHandler.cs
index d160e3339..776882aa5 100644
--- a/Emby.Dlna/Service/BaseControlHandler.cs
+++ b/Emby.Dlna/Service/BaseControlHandler.cs
@@ -150,12 +150,12 @@ namespace Emby.Dlna.Service
}
}
- return new ControlRequestInfo();
+ throw new EndOfStreamException("Stream ended but no body tag found.");
}
private async Task<ControlRequestInfo> ParseBodyTagAsync(XmlReader reader)
{
- var result = new ControlRequestInfo();
+ string namespaceURI = null, localName = null;
await reader.MoveToContentAsync().ConfigureAwait(false);
await reader.ReadAsync().ConfigureAwait(false);
@@ -165,11 +165,12 @@ namespace Emby.Dlna.Service
{
if (reader.NodeType == XmlNodeType.Element)
{
- result.LocalName = reader.LocalName;
- result.NamespaceURI = reader.NamespaceURI;
+ localName = reader.LocalName;
+ namespaceURI = reader.NamespaceURI;
if (!reader.IsEmptyElement)
{
+ var result = new ControlRequestInfo(localName, namespaceURI);
using (var subReader = reader.ReadSubtree())
{
await ParseFirstBodyChildAsync(subReader, result.Headers).ConfigureAwait(false);
@@ -187,7 +188,12 @@ namespace Emby.Dlna.Service
}
}
- return result;
+ if (localName != null && namespaceURI != null)
+ {
+ return new ControlRequestInfo(localName, namespaceURI);
+ }
+
+ throw new EndOfStreamException("Stream ended but no control found.");
}
private async Task ParseFirstBodyChildAsync(XmlReader reader, IDictionary<string, string> headers)
@@ -234,11 +240,18 @@ namespace Emby.Dlna.Service
private class ControlRequestInfo
{
+ public ControlRequestInfo(string localName, string namespaceUri)
+ {
+ LocalName = localName;
+ NamespaceURI = namespaceUri;
+ Headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
+ }
+
public string LocalName { get; set; }
public string NamespaceURI { get; set; }
- public Dictionary<string, string> Headers { get; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
+ public Dictionary<string, string> Headers { get; }
}
}
}