using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
namespace Jellyfin.Server.Middleware
{
///
/// URL decodes the querystring before binding.
///
public class QueryStringDecodingMiddleware
{
private readonly RequestDelegate _next;
///
/// Initializes a new instance of the class.
///
/// The next delegate in the pipeline.
public QueryStringDecodingMiddleware(RequestDelegate next)
{
_next = next;
}
///
/// 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);
}
}
}