mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-04-29 23:06:24 +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
7
third_party/httpcache/LICENSE
vendored
Normal file
7
third_party/httpcache/LICENSE
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
Copyright © 2012 Greg Jones (greg.jones@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
2
third_party/httpcache/README.md
vendored
Normal file
2
third_party/httpcache/README.md
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
httpcache is a copy of <https://github.com/gregjones/httpcache>
|
||||
with only the cache control header parsing logic.
|
||||
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