aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Controllers/MediaInfoController.cs
diff options
context:
space:
mode:
authorCody Robibero <cody@robibe.ro>2021-07-09 09:07:22 -0600
committerCody Robibero <cody@robibe.ro>2021-07-09 09:07:22 -0600
commite7022cc3fc7f6973262ed5f5a2a33fbf8c659c58 (patch)
tree3c96420adf5134098cdd87aaed5420223c262f2f /Jellyfin.Api/Controllers/MediaInfoController.cs
parentd8b9f4dc2dafbdcc104529543f2c7a996499534e (diff)
Use asp validation and increase max size
Diffstat (limited to 'Jellyfin.Api/Controllers/MediaInfoController.cs')
-rw-r--r--Jellyfin.Api/Controllers/MediaInfoController.cs17
1 files changed, 1 insertions, 16 deletions
diff --git a/Jellyfin.Api/Controllers/MediaInfoController.cs b/Jellyfin.Api/Controllers/MediaInfoController.cs
index e330f02b6..ad11d0923 100644
--- a/Jellyfin.Api/Controllers/MediaInfoController.cs
+++ b/Jellyfin.Api/Controllers/MediaInfoController.cs
@@ -302,27 +302,12 @@ namespace Jellyfin.Api.Controllers
/// </summary>
/// <param name="size">The bitrate. Defaults to 102400.</param>
/// <response code="200">Test buffer returned.</response>
- /// <response code="400">Size has to be a numer between 0 and 10,000,000.</response>
/// <returns>A <see cref="FileResult"/> with specified bitrate.</returns>
[HttpGet("Playback/BitrateTest")]
[ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- [Produces(MediaTypeNames.Application.Octet)]
[ProducesFile(MediaTypeNames.Application.Octet)]
- public ActionResult GetBitrateTestBytes([FromQuery] int size = 102400)
+ public ActionResult GetBitrateTestBytes([FromQuery][Range(1, 100_000_000, ErrorMessage = "The requested size must be greater than 0 and less than 100,000,000")] int size = 102400)
{
- const int MaxSize = 10_000_000;
-
- if (size <= 0)
- {
- return BadRequest($"The requested size ({size}) is equal to or smaller than 0.");
- }
-
- if (size > MaxSize)
- {
- return BadRequest($"The requested size ({size}) is larger than the max allowed value ({MaxSize}).");
- }
-
byte[] buffer = ArrayPool<byte>.Shared.Rent(size);
try
{