Skip to content

Make HostMatcherPolicy DFA edges case-insensitive - #68670

Merged
javiercn merged 1 commit into
dotnet:mainfrom
halter73:halter73-fix-host-matcher-casing
Aug 21, 2026
Merged

javiercn merged 1 commit into
dotnet:mainfrom
halter73:halter73-fix-host-matcher-casing

Conversation

@halter73

@halter73 halter73 commented Aug 20, 2026 •

Copy link
Copy Markdown
Member

Host matching is ordinal-ignore-case at request time, but HostMatcherPolicy.EdgeKey previously used case-sensitive equality, hashing, and ordering. Equivalent host metadata could therefore be placed in separate DFA branches, removing valid fallback endpoints before later matcher policies ran.

This aligns edge identity with runtime matching while keeping ports exact and preserving the original host spelling. Regression coverage includes exact and wildcard hosts, fixed and wildcard ports, Unicode casing, duplicate suppression, endpoint ordering, and downstream policy selection through both static DFA and dynamic endpoint-selector paths.

Fixes: #68349

Copilot AI lite review requested due to automatic review settings August 20, 2026 18:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a host-routing correctness issue by making HostMatcherPolicy’s DFA edge identity (equality, hashing, and ordering) case-insensitive, aligning it with runtime host matching behavior (ordinal-ignore-case). This prevents semantically equivalent host constraints that differ only by casing from being split into separate DFA branches, which could otherwise drop valid fallback endpoints before later matcher policies run.

Changes:

  • Updated HostMatcherPolicy.EdgeKey comparison, equality, and hashing to use OrdinalIgnoreCase for host values while keeping port matching exact.
  • Added unit coverage ensuring GetEdges groups equivalent host strings case-insensitively, avoids duplicate endpoints for equivalent host entries, and does not group different ports.
  • Added an integration test that verifies equivalent hosts with different casing preserve candidate endpoints for downstream matcher policies (via a content-encoding policy interaction).
Show a summary per file
File Description
src/Http/Routing/src/Matching/HostMatcherPolicy.cs Makes EdgeKey ordering/equality/hashing case-insensitive for hosts to ensure DFA edge identity matches runtime host semantics.
src/Http/Routing/test/UnitTests/Matching/HostMatcherPolicyTest.cs Adds focused unit tests validating case-insensitive host edge grouping and correct port differentiation.
src/Http/Routing/test/UnitTests/Matching/HostMatcherPolicyIntegrationTestBase.cs Adds an end-to-end regression test ensuring equivalent-cased hosts don’t lose fallback candidates needed by later matcher policies.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

@halter73
halter73 requested a review from javiercn August 20, 2026 18:40
@javiercn
javiercn merged commit 7f64e1c into dotnet:main Aug 21, 2026
29 checks passed
@javiercn

Copy link
Copy Markdown
Member

/backport to release/11.0-rc1

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0-rc1 (link to workflow run)

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.

HostMatcherPolicy builds case-sensitive DFA edges although host matching is case-insensitive

3 participants