third_party/httpcache: add copy of parts of httpcache

This commit is contained in:
Will Norris 2025-04-28 23:28:37 -07:00
parent 0da52d1e25
commit c45e01c551
3 changed files with 35 additions and 0 deletions

26
third_party/httpcache/httpcache.go vendored Normal file
View file

@ -0,0 +1,26 @@
package httpcache
import (
"net/http"
"strings"
)
type cacheControl map[string]string
func parseCacheControl(headers http.Header) cacheControl {
cc := cacheControl{}
ccHeader := headers.Get("Cache-Control")
for _, part := range strings.Split(ccHeader, ",") {
part = strings.Trim(part, " ")
if part == "" {
continue
}
if strings.ContainsRune(part, '=') {
keyval := strings.Split(part, "=")
cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",")
} else {
cc[part] = ""
}
}
return cc
}