encode: Slight fix for the previous commit

This commit is contained in:
Matthew Holt 2024-04-17 19:59:10 -06:00
parent 3067074d9c
commit 9ab09433de
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5

View file

@ -164,9 +164,12 @@ func (enc *Encode) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyh
// we have to strip our addition so the upstream handlers can still honor client // we have to strip our addition so the upstream handlers can still honor client
// caches without knowing about our changes... // caches without knowing about our changes...
if etag := r.Header.Get("If-None-Match"); etag != "" && !strings.HasPrefix(etag, "W/") { if etag := r.Header.Get("If-None-Match"); etag != "" && !strings.HasPrefix(etag, "W/") {
etag = strings.TrimSuffix(etag, "-"+encName+`"`) + `"` ourSuffix := "-" + encName + `"`
if strings.HasSuffix(etag, ourSuffix) {
etag = strings.TrimSuffix(etag, ourSuffix) + `"`
r.Header.Set("If-None-Match", etag) r.Header.Set("If-None-Match", etag)
} }
}
break break
} }