Skip to content

fix(vhost): match virtual host names case-insensitively - #3212

Open
arpitjain099 wants to merge 1 commit into
labstack:masterfrom
arpitjain099:fix/vhost-host-case
Open

arpitjain099 wants to merge 1 commit into
labstack:masterfrom
arpitjain099:fix/vhost-host-case

Conversation

@arpitjain099

Copy link
Copy Markdown

NewVirtualHostHandler looks the request host up in the map exactly as it arrived, so Host: OK.com misses an instance registered as ok.com and falls through to the fallback Echo instance, which usually has different routes and middleware. Host names are case insensitive (RFC 9110 Section 4.2.3), and non-browser clients do send mixed case. This lowercases the keys once at construction and lowercases r.Host on lookup. Copying the map is a small behaviour change: mutating it after construction no longer affects routing, and the doc comment now says so. I added one row to the existing table test.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
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.

1 participant