Skip to content

fix(net/ghttp): normalize method case before route cache lookup#4796

Closed
sonnemusk wants to merge 2 commits into
gogf:masterfrom
sonnemusk:fix/ghttp-method-case-route-cache
Closed

fix(net/ghttp): normalize method case before route cache lookup#4796
sonnemusk wants to merge 2 commits into
gogf:masterfrom
sonnemusk:fix/ghttp-method-case-route-cache

Conversation

@sonnemusk

Copy link
Copy Markdown

Fixes #4765

serveHandlerKey already upper-cases the method for cache keys, but getHandlersWithCache used the raw request method for search. So a lowercase get miss got stored under GET:/path and later real GET requests kept hitting that empty cache entry until restart.

Change:

  • strings.ToUpper(r.Method) before search/cache
  • same for Access-Control-Request-Method on OPTIONS

Test: Test_Router_LowercaseMethodCache (raw http.NewRequest("get", ...) then normal GET)

go test ./net/ghttp/ -run Test_Router_LowercaseMethodCache

serveHandlerKey already upper-cases the method for cache keys, but
search used the raw request method. A lowercase "get" miss was therefore
stored under "GET:..." and poisoned later real GET requests.

Also upper-case Access-Control-Request-Method for OPTIONS preflight.

Fixes gogf#4765
@sonnemusk

Copy link
Copy Markdown
Author

Closing to keep only high-signal open PRs. Sorry for the noise.

@sonnemusk sonnemusk closed this Jul 23, 2026
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.

ghttp: Lowercase HTTP request methods causing route cache pollution

1 participant