This commit is contained in:
cjd
2025-11-04 21:09:16 +08:00
parent 8260e293c7
commit bb90a020dc
592 changed files with 61749 additions and 27 deletions

View File

@@ -0,0 +1,21 @@
using System.IO;
using DouyinApi.Common.Https;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http.Features;
namespace DouyinApi.Extensions.Middlewares;
public static class FluentResponseBodyMiddleware
{
public static IApplicationBuilder UseResponseBodyRead(this IApplicationBuilder app)
{
return app.Use(async (context, next) =>
{
await using var swapStream = new FluentHttpResponseStream(context!.Features!.Get<IHttpResponseBodyFeature>()!,
context!.Features!.Get<IHttpBodyControlFeature>()!);
context.Response.Body = swapStream;
await next(context);
context.Response.Body.Seek(0, SeekOrigin.Begin);
});
}
}