MCPcopy
hub / github.com/willnorris/imageproxy / ParseCacheControl

Function ParseCacheControl

third_party/httpcache/httpcache.go:11–27  ·  view source on GitHub ↗
(headers http.Header)

Source from the content-addressed store, hash-verified

9type CacheControl map[string]string
10
11func ParseCacheControl(headers http.Header) CacheControl {
12 cc := CacheControl{}
13 ccHeader := headers.Get("Cache-Control")
14 for _, part := range strings.Split(ccHeader, ",") {
15 part = strings.Trim(part, " ")
16 if part == "" {
17 continue
18 }
19 if strings.ContainsRune(part, '=') {
20 keyval := strings.Split(part, "=")
21 cc[strings.ToLower(strings.Trim(keyval[0], " "))] = strings.Trim(keyval[1], ",")
22 } else {
23 cc[strings.ToLower(part)] = ""
24 }
25 }
26 return cc
27}
28
29func (cc CacheControl) String() string {
30 parts := make([]string, 0, len(cc))

Callers

nothing calls this directly

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected