diff options
| author | Cody Robibero <cody@robibe.ro> | 2023-02-04 10:21:49 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-04 10:21:49 -0700 |
| commit | d1af317d98a6190711af406af17b569844aebbd7 (patch) | |
| tree | 3422bb577d2821a9798465439e983932690aa2e3 /Jellyfin.Api/Middleware/QueryStringDecodingMiddleware.cs | |
| parent | e0519189b25bc4605889e46d9583fea9aef41732 (diff) | |
| parent | dfea1229e12764a77f5d392194b1848f80b87042 (diff) | |
Merge pull request #9215 from Shadowghost/api-scoped-namespace
Diffstat (limited to 'Jellyfin.Api/Middleware/QueryStringDecodingMiddleware.cs')
| -rw-r--r-- | Jellyfin.Api/Middleware/QueryStringDecodingMiddleware.cs | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/Jellyfin.Api/Middleware/QueryStringDecodingMiddleware.cs b/Jellyfin.Api/Middleware/QueryStringDecodingMiddleware.cs index 4b6304e0e..cb4169e99 100644 --- a/Jellyfin.Api/Middleware/QueryStringDecodingMiddleware.cs +++ b/Jellyfin.Api/Middleware/QueryStringDecodingMiddleware.cs @@ -2,38 +2,37 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; -namespace Jellyfin.Api.Middleware +namespace Jellyfin.Api.Middleware; + +/// <summary> +/// URL decodes the querystring before binding. +/// </summary> +public class QueryStringDecodingMiddleware { + private readonly RequestDelegate _next; + /// <summary> - /// URL decodes the querystring before binding. + /// Initializes a new instance of the <see cref="QueryStringDecodingMiddleware"/> class. /// </summary> - public class QueryStringDecodingMiddleware + /// <param name="next">The next delegate in the pipeline.</param> + public QueryStringDecodingMiddleware(RequestDelegate next) { - private readonly RequestDelegate _next; + _next = next; + } - /// <summary> - /// Initializes a new instance of the <see cref="QueryStringDecodingMiddleware"/> class. - /// </summary> - /// <param name="next">The next delegate in the pipeline.</param> - public QueryStringDecodingMiddleware(RequestDelegate next) + /// <summary> + /// Executes the middleware action. + /// </summary> + /// <param name="httpContext">The current HTTP context.</param> + /// <returns>The async task.</returns> + public async Task Invoke(HttpContext httpContext) + { + var feature = httpContext.Features.Get<IQueryFeature>(); + if (feature is not null) { - _next = next; + httpContext.Features.Set<IQueryFeature>(new UrlDecodeQueryFeature(feature)); } - /// <summary> - /// Executes the middleware action. - /// </summary> - /// <param name="httpContext">The current HTTP context.</param> - /// <returns>The async task.</returns> - public async Task Invoke(HttpContext httpContext) - { - var feature = httpContext.Features.Get<IQueryFeature>(); - if (feature is not null) - { - httpContext.Features.Set<IQueryFeature>(new UrlDecodeQueryFeature(feature)); - } - - await _next(httpContext).ConfigureAwait(false); - } + await _next(httpContext).ConfigureAwait(false); } } |
