Files
Prowlarr-Prowlarr/src/Prowlarr.Http/Middleware/BufferingMiddleware.cs
ta264 e81c6016a1 New: Use native dotnet host and DryIoc
(cherry picked from commit d6170dbfedf27a6218afe242a0fae2eb8b368aec)
2021-03-16 19:29:49 +00:00

31 lines
767 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
namespace Prowlarr.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);
}
}
}