aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server/Formatters/XmlOutputFormatter.cs
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-08-17 15:54:40 -0600
committercrobibero <cody@robibe.ro>2020-08-17 15:54:40 -0600
commit29d8e3816135b1af926eaf9c44f96638ce5956fe (patch)
tree813280744e6e5542fc595287d7991c2a7bdf1779 /Jellyfin.Server/Formatters/XmlOutputFormatter.cs
parent7861c72754172a1d2ebaffdde861fd614fa65488 (diff)
parentd0f49b39945424e5d2a8697ea551055ce26cf758 (diff)
Merge remote-tracking branch 'upstream/master' into fixes
Diffstat (limited to 'Jellyfin.Server/Formatters/XmlOutputFormatter.cs')
-rw-r--r--Jellyfin.Server/Formatters/XmlOutputFormatter.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/Jellyfin.Server/Formatters/XmlOutputFormatter.cs b/Jellyfin.Server/Formatters/XmlOutputFormatter.cs
new file mode 100644
index 000000000..58319657d
--- /dev/null
+++ b/Jellyfin.Server/Formatters/XmlOutputFormatter.cs
@@ -0,0 +1,31 @@
+using System.Net.Mime;
+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(MediaTypeNames.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());
+ }
+ }
+}