Skip to content

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.

3 participants