2021-05-15 19:24:41 +00:00
|
|
|
|
using System.Collections.Generic;
|
2021-05-07 13:37:26 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
2021-06-13 12:30:28 +00:00
|
|
|
|
namespace Jellyfin.Server.Integration.Tests.Controllers
|
2021-05-07 13:37:26 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2021-05-15 19:24:41 +00:00
|
|
|
|
/// Controller for testing the encoded url.
|
2021-05-07 13:37:26 +00:00
|
|
|
|
/// </summary>
|
2021-06-13 12:30:28 +00:00
|
|
|
|
public class EncoderController : BaseJellyfinTestController
|
2021-05-07 13:37:26 +00: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>
|
2021-05-07 17:51:04 +00:00
|
|
|
|
[HttpGet("UrlDecode")]
|
2021-05-07 13:37:26 +00:00
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2021-06-07 15:21:30 +00:00
|
|
|
|
public ContentResult TestUrlDecoding([FromQuery] Dictionary<string, string>? @params = null)
|
2021-05-07 13:37:26 +00:00
|
|
|
|
{
|
2021-05-07 19:11:32 +00:00
|
|
|
|
return new ContentResult()
|
2021-05-07 13:37:26 +00:00
|
|
|
|
{
|
2021-05-07 19:11:32 +00: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 13:37:26 +00:00
|
|
|
|
}
|
2021-06-08 20:26:59 +00: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 13:37:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|