Skip to content

Commit 9ab0943

Browse files
committed
encode: Slight fix for the previous commit
1 parent 3067074 commit 9ab0943

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

modules/caddyhttp/encode/encode.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,11 @@ func (enc *Encode) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyh
164164
// we have to strip our addition so the upstream handlers can still honor client
165165
// caches without knowing about our changes...
166166
if etag := r.Header.Get("If-None-Match"); etag != "" && !strings.HasPrefix(etag, "W/") {
167-
etag = strings.TrimSuffix(etag, "-"+encName+`"`) + `"`
168-
r.Header.Set("If-None-Match", etag)
167+
ourSuffix := "-" + encName + `"`
168+
if strings.HasSuffix(etag, ourSuffix) {
169+
etag = strings.TrimSuffix(etag, ourSuffix) + `"`
170+
r.Header.Set("If-None-Match", etag)
171+
}
169172
}
170173

171174
break

0 commit comments

Comments
 (0)