-
Notifications
You must be signed in to change notification settings - Fork 68
Closed
Labels
Needs: Triage 🔍Label added to new issues which need TriageLabel added to new issues which need Triage
Description
Summary
Hi, I am migrating a web to net core. The line 68 enable response buffering if HttpApplication events are needed. This disables our cache policy in later code.
Lines 59 to 81 in c2607be
| internal static void UseSystemWebAdapterFeatures(this IApplicationBuilder app) | |
| { | |
| if (app.HasBeenAdded()) | |
| { | |
| return; | |
| } | |
| if (app.AreHttpApplicationEventsRequired()) | |
| { | |
| app.UseMiddleware<HttpApplicationMiddleware>(); | |
| } | |
| app.UseMiddleware<PreBufferRequestStreamMiddleware>(); | |
| app.UseMiddleware<BufferResponseStreamMiddleware>(); | |
| app.UseMiddleware<SetDefaultResponseHeadersMiddleware>(); | |
| app.UseMiddleware<SingleThreadedRequestMiddleware>(); | |
| app.UseMiddleware<CurrentPrincipalMiddleware>(); | |
| if (app.AreHttpApplicationEventsRequired()) | |
| { | |
| app.UseHttpApplicationEvent(ApplicationEvent.BeginRequest); | |
| } | |
| } |
Motivation and goals
Allow user code to manage response buffering feature.
Risks / unknowns
Can anyone provide some insights for this design?
Repro
builder.Services.AddSystemWebAdapters()
.AddWrappedAspNetCoreSession()
.AddHttpApplication<MyApp>(options =>
{
options.RegisterModule<MyModule>("Module1");
options.RegisterModule<MyModule>("Module2");
options.RegisterModule<MyModule>("Module3");
.......
});
var app = builder.Build();
// Since HttpApplication events are needed, here will add `HttpApplicationMiddleware`.
app.UseSystemWebAdapters();
app.Use((context, next) =>
{
// This will not success because `HttpApplicationMiddleware` will enable buffering.
if(!ShouldBufferReponse(context.Request.Path))
context.Features.Get<IHttpResponseBodyFeature>().DisableBuffering();
return next();
});Here is where updated the response buffering.
Line 18 in c2607be
| context.Features.GetRequired<IHttpResponseBufferingFeature>().EnableBuffering(BufferResponseStreamAttribute.DefaultMemoryThreshold, default); |
Metadata
Metadata
Assignees
Labels
Needs: Triage 🔍Label added to new issues which need TriageLabel added to new issues which need Triage