Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make IHttpOutputAborter public #60205

Closed
maruyama-tomo opened this issue Feb 5, 2025 · 2 comments
Closed

Make IHttpOutputAborter public #60205

maruyama-tomo opened this issue Feb 5, 2025 · 2 comments
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Comments

@maruyama-tomo
Copy link

Background and Motivation

When there are cache servers (nginx, varnish, etc) in front of ASP.NET Core, and responding chunked body, we can tell them not to cache the response by aborting the output.
It is useful if retriable errors may occur while generating length-unknown chunked responses.

Proposed API

-internal interface IHttpOutputAborter
+public interface IHttpOutputAborter

Usage Examples

response.HttpContext.Features.Get<IHttpOutputAborter>()?.Abort(exception);

// currently, we are using above via reflection
//
// var aborter = response.HttpContext.Features.GetType().GetInterface("IHttpOutputAborter");
// aborter?.GetMethod("Abort")?.Invoke(response.HttpContext.Features, new[] { exception });

Alternative Designs

Porting System.Web's HttpResponse.Close() method also would be nice.

Risks

I don't think any risk so far.

@maruyama-tomo maruyama-tomo added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Feb 5, 2025
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Feb 5, 2025
@davidfowl
Copy link
Member

https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.httpcontext.abort?view=aspnetcore-9.0

@maruyama-tomo
Copy link
Author

Thank you for pointing the existing API!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

No branches or pull requests

2 participants