aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server/Formatters/XmlOutputFormatter.cs
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2020-08-16 17:03:19 +0200
committerGitHub <noreply@github.com>2020-08-16 17:03:19 +0200
commit357b72fb8194a0a1a5b7962c0979b358926afef5 (patch)
tree005b16e9094835bde04df835737715f40200e6e5 /Jellyfin.Server/Formatters/XmlOutputFormatter.cs
parent0f85e66962220de17bd632ad4a0d1465324e166c (diff)
parent09c859746116a949008ebba832fa17b55c90e6e4 (diff)
Merge pull request #3903 from crobibero/xml-formatter
Add xml output formatter
Diffstat (limited to 'Jellyfin.Server/Formatters/XmlOutputFormatter.cs')
-rw-r--r--Jellyfin.Server/Formatters/XmlOutputFormatter.cs30
1 files changed, 30 insertions, 0 deletions
diff --git a/Jellyfin.Server/Formatters/XmlOutputFormatter.cs b/Jellyfin.Server/Formatters/XmlOutputFormatter.cs
new file mode 100644
index 000000000..5f2337b2a
--- /dev/null
+++ b/Jellyfin.Server/Formatters/XmlOutputFormatter.cs
@@ -0,0 +1,30 @@
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc.Formatters;
+
+namespace Jellyfin.Server.Formatters
+{
+ /// <summary>
+ /// Xml output formatter.
+ /// </summary>
+ public class XmlOutputFormatter : TextOutputFormatter
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="XmlOutputFormatter"/> class.
+ /// </summary>
+ public XmlOutputFormatter()
+ {
+ SupportedMediaTypes.Add("text/xml");
+ SupportedMediaTypes.Add("text/xml;charset=UTF-8");
+ SupportedEncodings.Add(Encoding.UTF8);
+ SupportedEncodings.Add(Encoding.Unicode);
+ }
+
+ /// <inheritdoc />
+ public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
+ {
+ return context.HttpContext.Response.WriteAsync(context.Object?.ToString());
+ }
+ }
+}