using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.Logging; namespace Jellyfin.Server.Middleware { /// /// URL decodes the querystring before binding. /// public class QueryStringDecodingMiddleware { private readonly RequestDelegate _next; private readonly ILogger _logger; /// /// Initializes a new instance of the class. /// /// The next delegate in the pipeline. /// The logger. public QueryStringDecodingMiddleware( RequestDelegate next, ILogger logger) { _next = next; _logger = logger; } /// /// Executes the middleware action. /// /// The current HTTP context. /// The async task. public async Task Invoke(HttpContext httpContext) { httpContext.Features.Set(new UrlDecodeQueryFeature(httpContext.Features.Get())); await _next(httpContext).ConfigureAwait(false); } } }