- In the case that other middleware change the path of an `HttpContext` and cause middleware to re-invoke we used to short-circuit on second time through the middleware pipeline, now we allow routing to occur.
- Added unit tests to validate the clearing of state.
#11233
- This change goes from pooling just the HttpContext to pooling the entire TContext. In the past this was a huge struct that got copied around and now it can be a class. Servers can provide the storage for the TContext via a new `IHostContextContainer<TContext>` interface.
- Removed IDefaultHttpContextContainer since it's been superseded by IHostContextContainer
- Move DefaultHttpContextFactory to Hosting to take advantage of internal methods
- Also handle a null FeatureCollection and null HttpContext and throw a better exception
- We were looking all total consumed bytes instead of bytes consumed since the last time we parsed a form value. This resulted in thinking that the key or value was too long if it couldn't be parsed after having parsed a bunch of data in the same read.
- Added tests
The only pubternal that remains is DfaGraphWriter - it's a good use case
for pubternal because it's something we want to expose, but we'd never
service and would willingly break the API in the future. It's also
really unlikly that anyone would build on top of it.
* Add a diagnostic source event that fires when a route is matched
- Usually more information becomes available about a request once route is matched. This event shoud allow diagnositc systems to enlighten the typical "begin request" metadata to include more information about the matched route and more importantly the selected endpoint and associated metadata.
* Update src/Http/Routing/test/UnitTests/EndpointRoutingMiddlewareTest.cs
Co-Authored-By: campersau <buchholz.bastian@googlemail.com>
* PR feedback and test fixes
* Added some doc comments to bedrock APIs
- Also cleaned up some HttpContext doc comments
* Apply suggestions from code review
PR feedback
Co-Authored-By: Andrew Stanton-Nurse <andrew@stanton-nurse.com>
* Apply suggestions from code review
Co-Authored-By: Justin Kotalik <jukotali@microsoft.com>
Adds infrastructure for a common IRouter-based pattern. In this pattern,
an extender subclasses Route to post-process the route values before MVC
action selection run. The new infrastructure duplicates this kind of
experience but based on endpoint routing.
The approach in this PR starts at the bottom... meaning that this is the
most-focused and least-invasive way to implement a feature like this.
Similar to fallback routing, this is a pattern built with matcher
policies and metadata rather than a built-in feature of routing.
It's valuable to point out that this approach uses IActionConstraint to
disambiguate between actions. The other way we could go would be to make
the *other* matcher policy implementations able to do this. This would
mean that whenever you have a dynamic endpoint, you will not by using
the DFA for features like HTTP methods. It also means that we need to go
re-implement a bunch of infrastructure.
This PR also adds the concept of an 'inert' endpoint - a non-Routable
endpoint that's created when fallback/dynamic is in use. This seems like
a cleaner design because we don't start *matching* RouteEndpoint
instances for URLs that don't match. This resolves#8130
* Read interface IList.Count once rather than per iteration
Inspired by #9962, read .Count once rather than once per loop iteration.
* Use nameof() instead of ToString()
Use constant nameof() on enum value, rather than runtime ToString().
* Right-size dictionary
Initialize dictionary with a fixed number of elements to the number of elements it contains.
* Use DisposeAsync()
Use DisposeAsync() on FileBufferingReadStream in input formatters.
* Override DisposeAsync()
Override DisposeAsync() to call DisposeAsync() on the inner stream.
* Use GetValueOrDefault() for content-length
Use GetValueOrDefault() to read the content length once instead of checking HasValue once and Value up to three times.
* Update Microsoft.AspNetCore.WebUtilities.netcoreapp3.0.cs
Add DisposeAsync().
* Use DisposeAsync()
Use DisposeAsync() on transcoding streams as other formatters do.
- Remove string allocations caused by DiagnosticSource.Stop/StartActivity
- Pass the HttpContext directly as the object for StartActivity and StopActivity to avoid the anonymous object allocation.
- Though it's a bit ugly, added an HttpContext property to DefaultHttpContext to avoid breaking back-compat (which had to do reflection to get the HttpContext property anyways)
* Update build.cmd to install .NET Core into $repoRoot/.dotnet instead of $repoRoot/.dotnet/x64
* Move restore sources from build/sources.props into eng/Versions.props (following arcade conventions)
* Remove usages of RuntimeFrameworkVersion in tests and build
* Update Blazor VSIX to use Arcade VSIX tools
* Rename Common.Tests to IIS.Common.TestLib and make it a test asset
* Remove custom versions props for ANCM installer code
* Remove duplicate references to xunit and remove usages of IsTestProject
* Remove duplicate references to Internal.AspNetCore.Analyzers
* Import Arcade.Sdk props and targets and remove custom versioning props
* Remove references to Internal.AspNetCore.Sdk
* Rename PackageLicenseType => PackageLicenseExpression
* Remove dependency on tasks in Internal.AspNetCore.Sdk, add ref to Internal.AspNetCore.BuildTasks as a temporary workaround
* Use Arcade's nuspec support
* Rename SignalR.Client.FunctionalTests to SignalR.Client.FunctionalTestApp
* Fixes for changes to property evaluation order
* Update BaseLineGenerator to netcoreapp3.0
* React to changes in evaluation order in RPM files and quirks in using <Exec> instead of <Run>
* Update Microsoft.Extensions.ApiDescription.Server to react to changes in Arcade packaging
* Workaround aspnet/AspNetCore#11009
* EndpointMiddleware does not invoke endpoint
Fixes: #10649
The bug is that the endpoint delegate is not invoked when
SuppressCheckForUnhandledSecurityMetadata is set to true. This option is
provided so that can you suppress the security checks done by routing,
but right now what it does is suppress the entire middleware.
We had tests for the supression cases, but they didn't actually validate
that the middleware did any work, just that we don't throw. Fixed that.
* harden tests
The Arcade SDK requires that the obj/ and bin/ folders be placed in the top-level artifacts/ folder of the repo. Although this PR does not complete our Arcade convergence, this is a step towards updating our repo to build with the Arcade SDK.
Changes:
* Set output path for build to artifacts/bin/$(ProjectName)/
* Set intermediate output path for build to artifacts/obj/$(ProjectName)/
* Cleanup .gitignore files (remove duplication between repo-root and tested gitignore files)
* Add code check which looks for project files that share the same name (could cause issues)
* Rename project files to have unique names (avoid race condition of build output)
* Update all locations which were hard-coded to expect bin/ and obj/ in the project directory
* Add overrides for tests which still assert test binaries exist in a given location relative to the source code