jellyfin/tests/Jellyfin.Server.Integration.Tests/Controllers/EncoderController.cs

54 lines
2 KiB
C#
Raw Normal View History

2021-05-15 21:24:41 +02:00
using System.Collections.Generic;
2021-05-07 15:37:26 +02:00
using System.Linq;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
2021-06-13 14:30:28 +02:00
namespace Jellyfin.Server.Integration.Tests.Controllers
2021-05-07 15:37:26 +02:00
{
/// <summary>
2021-05-15 21:24:41 +02:00
/// Controller for testing the encoded url.
2021-05-07 15:37:26 +02:00
/// </summary>
2021-06-13 14:30:28 +02:00
public class EncoderController : BaseJellyfinTestController
2021-05-07 15:37:26 +02:00
{
/// <summary>
/// Tests the url decoding.
/// </summary>
/// <param name="params">Parameters to echo back in the response.</param>
/// <returns>An <see cref="OkResult"/>.</returns>
/// <response code="200">Information retrieved.</response>
[HttpGet("UrlDecode")]
2021-05-07 15:37:26 +02:00
[ProducesResponseType(StatusCodes.Status200OK)]
public ContentResult TestUrlDecoding([FromQuery] Dictionary<string, string>? @params = null)
2021-05-07 15:37:26 +02:00
{
2021-05-07 21:11:32 +02:00
return new ContentResult()
2021-05-07 15:37:26 +02:00
{
2021-05-07 21:11:32 +02:00
Content = (@params != null && @params.Count > 0)
? string.Join("&", @params.Select(x => x.Key + "=" + x.Value))
: string.Empty,
ContentType = "text/plain; charset=utf-8",
StatusCode = 200
};
2021-05-07 15:37:26 +02:00
}
/// <summary>
/// Tests the url decoding.
/// </summary>
/// <param name="params">Parameters to echo back in the response.</param>
/// <returns>An <see cref="OkResult"/>.</returns>
/// <response code="200">Information retrieved.</response>
[HttpGet("UrlArrayDecode")]
[ProducesResponseType(StatusCodes.Status200OK)]
public ContentResult TestUrlArrayDecoding([FromQuery] Dictionary<string, string[]>? @params = null)
{
return new ContentResult()
{
Content = (@params != null && @params.Count > 0)
? string.Join("&", @params.Select(x => x.Key + "=" + string.Join(',', x.Value)))
: string.Empty,
ContentType = "text/plain; charset=utf-8",
StatusCode = 200
};
}
2021-05-07 15:37:26 +02:00
}
}