diff --git a/configurationtypes/types.go b/configurationtypes/types.go index 4c0c7d02f..8093faebf 100644 --- a/configurationtypes/types.go +++ b/configurationtypes/types.go @@ -20,8 +20,6 @@ func (c *CacheKeys) parseJSON(rootDecoder *json.Decoder) { var token json.Token var err error - _, _ = rootDecoder.Token() - _, _ = rootDecoder.Token() _, _ = rootDecoder.Token() for err == nil { diff --git a/plugins/caddy/httpcache_test.go b/plugins/caddy/httpcache_test.go index b9f46fc43..8c3b8e7df 100644 --- a/plugins/caddy/httpcache_test.go +++ b/plugins/caddy/httpcache_test.go @@ -114,6 +114,43 @@ func TestQueryString(t *testing.T) { } } +func TestCacheKeys(t *testing.T) { + tester := caddytest.NewTester(t) + tester.InitServer(` + { + admin localhost:2999 + order cache before rewrite + http_port 9080 + https_port 9443 + cache + } + localhost:9080 { + route /cache-keys { + cache { + cache_keys { + query= { + disable_query + } + query2= { + disable_body + disable_host + } + } + } + respond "Hello, query string!" + } + }`, "caddyfile") + + resp1, _ := tester.AssertGetResponse(`http://localhost:9080/cache-keys?query=string`, 200, "Hello, query string!") + if resp1.Header.Get("Cache-Status") != "Souin; fwd=uri-miss; stored; key=GET-http-localhost:9080-/cache-keys" { + t.Errorf("unexpected Cache-Status header %v", resp1.Header) + } + resp2, _ := tester.AssertGetResponse(`http://localhost:9080/cache-keys?foo=bar`, 200, "Hello, query string!") + if resp2.Header.Get("Cache-Status") != "Souin; fwd=uri-miss; stored; key=GET-http-localhost:9080-/cache-keys?foo=bar" { + t.Errorf("unexpected Cache-Status header %v", resp2.Header) + } +} + func TestMaxAge(t *testing.T) { tester := caddytest.NewTester(t) tester.InitServer(`