mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-04-29 14:56:25 +02:00
third_party/httpcache: add copy of parts of httpcache
This commit is contained in:
parent
0da52d1e25
commit
c45e01c551
3 changed files with 35 additions and 0 deletions
26
third_party/httpcache/httpcache.go
vendored
Normal file
26
third_party/httpcache/httpcache.go
vendored
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue