aboutsummaryrefslogtreecommitdiff
path: root/Emby.Dlna/Service/BaseControlHandler.cs
diff options
context:
space:
mode:
authorBaronGreenback <jimcartlidge@yahoo.co.uk>2020-09-25 19:44:16 +0100
committerGitHub <noreply@github.com>2020-09-25 19:44:16 +0100
commit63571578ae04ec3b16f8cc5c5b2f9252de78aeda (patch)
tree4f81ad11a54006c9207953144c2e8fc239bd0193 /Emby.Dlna/Service/BaseControlHandler.cs
parenta52ab69e13d2b924522a21fa4da98f38ec298bd1 (diff)
Update BaseControlHandler.cs
Diffstat (limited to 'Emby.Dlna/Service/BaseControlHandler.cs')
-rw-r--r--Emby.Dlna/Service/BaseControlHandler.cs23
1 files changed, 18 insertions, 5 deletions
diff --git a/Emby.Dlna/Service/BaseControlHandler.cs b/Emby.Dlna/Service/BaseControlHandler.cs
index ea17773b1..39004d394 100644
--- a/Emby.Dlna/Service/BaseControlHandler.cs
+++ b/Emby.Dlna/Service/BaseControlHandler.cs
@@ -155,7 +155,7 @@ namespace Emby.Dlna.Service
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; }
}
}
}