You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
765 B
31 lines
765 B
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
namespace Lidarr.Http.Middleware
|
|
{
|
|
public class BufferingMiddleware
|
|
{
|
|
private readonly RequestDelegate _next;
|
|
private readonly List<string> _urls;
|
|
|
|
public BufferingMiddleware(RequestDelegate next, List<string> urls)
|
|
{
|
|
_next = next;
|
|
_urls = urls;
|
|
}
|
|
|
|
public async Task InvokeAsync(HttpContext context)
|
|
{
|
|
if (_urls.Any(p => context.Request.Path.StartsWithSegments(p, StringComparison.OrdinalIgnoreCase)))
|
|
{
|
|
context.Request.EnableBuffering();
|
|
}
|
|
|
|
await _next(context);
|
|
}
|
|
}
|
|
}
|