2020-08-16 17:48:54 +00:00
|
|
|
|
using System.Net.Mime;
|
|
|
|
|
using System.Text;
|
2020-08-15 16:39:24 +00:00
|
|
|
|
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()
|
|
|
|
|
{
|
2020-08-20 17:17:27 +00:00
|
|
|
|
SupportedMediaTypes.Clear();
|
2020-08-16 17:48:54 +00:00
|
|
|
|
SupportedMediaTypes.Add(MediaTypeNames.Text.Xml);
|
2020-08-20 17:17:27 +00:00
|
|
|
|
|
2020-08-15 16:39:24 +00:00
|
|
|
|
SupportedEncodings.Add(Encoding.UTF8);
|
|
|
|
|
SupportedEncodings.Add(Encoding.Unicode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
|
|
|
|
|
{
|
2020-11-13 16:03:44 +00:00
|
|
|
|
var stringResponse = context.Object?.ToString();
|
|
|
|
|
return stringResponse == null ? Task.CompletedTask : context.HttpContext.Response.WriteAsync(stringResponse);
|
2020-08-15 16:39:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|