From ce36ac58d8a6fef8bb0b03351d2974526c7926bb Mon Sep 17 00:00:00 2001 From: cchangwen <157893811+cchangwen@users.noreply.github.com> Date: Sat, 27 Jan 2024 21:52:13 +0800 Subject: [PATCH 1/3] ETag prefix W/ https://stackoverflow.com/questions/51973120/where-does-the-w-in-an-etag-appear-from https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag# --- modules/httpcache/httpcache.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/httpcache/httpcache.go b/modules/httpcache/httpcache.go index b57b3218322c7..5645a0e6b4945 100644 --- a/modules/httpcache/httpcache.go +++ b/modules/httpcache/httpcache.go @@ -58,6 +58,7 @@ func HandleGenericETagCache(req *http.Request, w http.ResponseWriter, etag strin func checkIfNoneMatchIsValid(req *http.Request, etag string) bool { ifNoneMatch := req.Header.Get("If-None-Match") if len(ifNoneMatch) > 0 { + ifNoneMatch = strings.TrimPrefix(ifNoneMatch, "W/") for _, item := range strings.Split(ifNoneMatch, ",") { item = strings.TrimSpace(item) if item == etag { From 4770069391145f0731ecfae88bc4934fac998848 Mon Sep 17 00:00:00 2001 From: cchangwen <157893811+cchangwen@users.noreply.github.com> Date: Sun, 28 Jan 2024 14:41:29 +0800 Subject: [PATCH 2/3] ETag TrimPrefix W/ --- modules/httpcache/httpcache.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/httpcache/httpcache.go b/modules/httpcache/httpcache.go index 5645a0e6b4945..f93e959588cd5 100644 --- a/modules/httpcache/httpcache.go +++ b/modules/httpcache/httpcache.go @@ -58,9 +58,8 @@ func HandleGenericETagCache(req *http.Request, w http.ResponseWriter, etag strin func checkIfNoneMatchIsValid(req *http.Request, etag string) bool { ifNoneMatch := req.Header.Get("If-None-Match") if len(ifNoneMatch) > 0 { - ifNoneMatch = strings.TrimPrefix(ifNoneMatch, "W/") for _, item := range strings.Split(ifNoneMatch, ",") { - item = strings.TrimSpace(item) + item = strings.TrimPrefix(strings.TrimSpace(item), "W/") if item == etag { return true } From 75f12a5c1f97d257d9ea72d29cec022d9770047f Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 29 Jan 2024 21:22:38 +0800 Subject: [PATCH 3/3] Update modules/httpcache/httpcache.go Co-authored-by: delvh --- modules/httpcache/httpcache.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/httpcache/httpcache.go b/modules/httpcache/httpcache.go index f93e959588cd5..40458dfc336e0 100644 --- a/modules/httpcache/httpcache.go +++ b/modules/httpcache/httpcache.go @@ -59,7 +59,7 @@ func checkIfNoneMatchIsValid(req *http.Request, etag string) bool { ifNoneMatch := req.Header.Get("If-None-Match") if len(ifNoneMatch) > 0 { for _, item := range strings.Split(ifNoneMatch, ",") { - item = strings.TrimPrefix(strings.TrimSpace(item), "W/") + item = strings.TrimPrefix(strings.TrimSpace(item), "W/") // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag#directives if item == etag { return true }