MCPcopy
hub / github.com/gofiber/fiber / hasDirective

Function hasDirective

middleware/cache/cachecontrol.go:11–34  ·  view source on GitHub ↗

hasDirective checks if a cache directive header value contains a directive (case-insensitive). A directive is considered matched when followed by end-of-string, ',', ' ', '\t', or '=' per RFC 9111 §5.2.

(cc, directive string)

Source from the content-addressed store, hash-verified

9// A directive is considered matched when followed by end-of-string, ',', ' ', '\t', or '='
10// per RFC 9111 §5.2.
11func hasDirective(cc, directive string) bool {
12 ccLen := len(cc)
13 dirLen := len(directive)
14 for i := 0; i <= ccLen-dirLen; i++ {
15 if !utils.EqualFold(cc[i:i+dirLen], directive) {
16 continue
17 }
18 if i > 0 {
19 prev := cc[i-1]
20 if prev != ' ' && prev != ',' && prev != '\t' {
21 continue
22 }
23 }
24 if i+dirLen == ccLen {
25 return true
26 }
27 next := cc[i+dirLen]
28 if next == ',' || next == ' ' || next == '\t' || next == '=' {
29 return true
30 }
31 }
32
33 return false
34}
35
36func parseUintDirective(val []byte) (uint64, bool) {
37 if len(val) == 0 {

Callers 2

NewFunction · 0.85
Test_hasDirectiveFunction · 0.85

Calls

no outgoing calls

Tested by 1

Test_hasDirectiveFunction · 0.68