Skip to content

Commit

Permalink
Merge pull request #45 from btm6084/hostfix
Browse files Browse the repository at this point in the history
Update cache key generation to have a fallback if host has no port.
  • Loading branch information
bmaynortcg committed Aug 7, 2023
2 parents 8b6eb70 + 75df6f4 commit 6e70e45
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cache/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ func HandlerWrapper(cacheDuration int, next http.Handler) http.HandlerFunc {
}

m := metrics.GetRecorder(r.Context())
host, _, _ := net.SplitHostPort(r.Host)
host, _, err := net.SplitHostPort(r.Host)
if err != nil {
host = strings.Trim(r.Host, `"' ,`)
}

key := host + r.Method + r.RequestURI + r.Header.Get("range")

if handlerTryCache(w, r, m, key, d) {
Expand Down

0 comments on commit 6e70e45

Please sign in to comment.