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

Add support for multi-value header routing #1639

Merged
merged 2 commits into from
Apr 20, 2022

Conversation

MihaZupan
Copy link
Member

Fixes #1494

Matching now treats multiple values as ORs. I.e. Exact/Prefix must match any of the request values.
NotContains means the value must not match any request header.

Values are further split based on the separator , (or ; for Cookie). A single outer pair of quotes is also removed before matching.

This PR is generally slightly faster on simple (single-value) inputs, and (as expected) slower on multi-value ones.
Modes that may observe a perf degradation are Exact and Prefix.
I don't think the difference is prohibitive to the point that having an opt-out switch is needed.

Benchmark scenarios are defined here.

Method Scenario Mean Error StdDev Ratio
Old SimpleContains 292.78 ns 0.957 ns 0.848 ns 1.00
New SimpleContains 243.82 ns 0.823 ns 0.687 ns 0.83
Old SimpleExact 158.98 ns 0.529 ns 0.469 ns 1.00
New SimpleExact 117.40 ns 0.236 ns 0.184 ns 0.74
Old SimplePrefix 104.09 ns 0.284 ns 0.222 ns 1.00
New SimplePrefix 97.69 ns 0.512 ns 0.454 ns 0.94
Old MultipleContains 294.57 ns 1.679 ns 1.402 ns 1.00
New MultipleContains 291.51 ns 3.079 ns 2.880 ns 0.99
Old MultipleExact 124.28 ns 0.237 ns 0.185 ns 1.00
New MultipleExact 175.34 ns 0.626 ns 0.523 ns 1.41
Old MultiplePrefix 130.89 ns 1.529 ns 1.431 ns 1.00
New MultiplePrefix 176.16 ns 0.513 ns 0.428 ns 1.35

ToDo: Updating docs with the new behavior

@MihaZupan MihaZupan added this to the YARP 1.1.0 milestone Apr 7, 2022
@MihaZupan MihaZupan requested a review from Tratcher as a code owner April 7, 2022 10:43
@MihaZupan MihaZupan self-assigned this Apr 7, 2022
src/ReverseProxy/Routing/HeaderMatcher.cs Outdated Show resolved Hide resolved
src/ReverseProxy/Routing/HeaderMatcherPolicy.cs Outdated Show resolved Hide resolved
@MihaZupan MihaZupan enabled auto-merge (squash) April 20, 2022 15:23
@MihaZupan MihaZupan merged commit b24e71c into microsoft:main Apr 20, 2022
MihaZupan added a commit to MihaZupan/reverse-proxy that referenced this pull request Apr 28, 2022
Tratcher pushed a commit that referenced this pull request Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi-value header routing support
2 participants