Repository navigation
fix: trim optional whitespace in cache-control directives - #320
Open
dajiaohuang wants to merge 1 commit into
Open
dajiaohuang wants to merge 1 commit into
dajiaohuang wants to merge 1 commit into
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
farkmi
requested changes
Oct 27, 2026
| @@ -0,0 +1,20 @@ | |||
| package util | |||
Collaborator
There was a problem hiding this comment.
Thanks for the fix, it’s spot on. One small thing before we merge: could you switch the test to package util_test and use testify (assert.Equal(t, want, util.ParseCacheControlHeader(input))) so it matches the other tests in internal/util? Feel free to move it into cache_control_test.go too, but a separate file is fine. Happy to merge once that’s in.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
ParseCacheControlHeader("no-cache, no-store")currently returns onlyno-cache, because the second directive retains its leading space. The request middleware passes this incomplete bitmask into the request context.Trim optional spaces and tabs from directive names before matching. Add five offline parser cases covering compact lists, spaces, tabs, mixed case and unrelated directives.
Validation: four whitespace regression cases fail before the change; all five pass after it using
go test cache_control.go context.go cache_control_parser_test.go -count=1frominternal/util.git diff --checkalso passes. The full service/database integration suite was not run; no database, Docker daemon or deployed service was used.PR Type
Bug fix, Tests
Description
Trim whitespace in cache-control directives
Add tests for cache-control parsing
Diagram Walkthrough
File Walkthrough
cache_control.go
Trim whitespace in directive parsinginternal/util/cache_control.go
cache_control_parser_test.go
Add tests for cache-control parsinginternal/util/cache_control_parser_test.go
TestParseCacheControlWhitespaceto verify parsing behavior.