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

Implement HttpContext against Core HttpContext #427

Merged
merged 4 commits into from
Feb 14, 2022

Conversation

twsouthwick
Copy link
Contributor

This change starts plumbing ASP.NET Core HttpContext through the HttpContext
and sets up the caching mechanism used to ensure only a single instance
of the HttpContext is created per context.

Conversion between the adapters and core types are provided via both
implicit operators as well as extension methods that get or unwrap the
adapters. The HttpContext adapter is stored in the core
HttpContext.Features so that only a single instance is used for each
instance of the core context. The additional members (such as .Request
or .Response) are cached within the adapters and only created on demand.

This change also includes the HttpContextWrapper, HttpRequestWrapper,
and HttpResponseWrapper which are converted and stored in a similar way
as to the HttpContext adapter.

This change starts plumbing ASP.NET Core HttpContext through the HttpContext
and sets up the caching mechanism used to ensure only a single instance
of the HttpContext is created per context.

Conversion between the adapters and core types are provided via both
implicit operators as well as extension methods that get or unwrap the
adapters. The HttpContext adapter is stored in the core
HttpContext.Features so that only a single instance is used for each
instance of the core context. The additional members (such as .Request
or .Response) are cached within the adapters and only created on demand.

This change also includes the HttpContextWrapper, HttpRequestWrapper,
and HttpResponseWrapper which are converted and stored in a similar way
as to the HttpContext adapter.
@twsouthwick
Copy link
Contributor Author

/cc @davidfowl @pranavkm

I'm especially interested in your thoughts of storing the adapter in HttpContext.Features. I could swap it to use .Items, but this seems like it would have a bit better perf for those who are using it often since .Items is built on the .Features.

@davidfowl
Copy link
Member

I'm especially interested in your thoughts of storing the adapter in HttpContext.Features. I could swap it to use .Items, but this seems like it would have a bit better perf for those who are using it often since .Items is built on the .Features.

This is good (this was my idea as well).
FeelMeThinkAboutItGIF (2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants