From 1aa9f0e51fb2956c8d9d20cfb448f2b5507f39d0 Mon Sep 17 00:00:00 2001 From: mritd Date: Sun, 27 Jun 2021 11:51:10 +0800 Subject: [PATCH 1/3] feat(fileserver): add 'canonical_uris' parameter to caddyfile add 'canonical_uris' parameter to caddyfile reference #2741 Signed-off-by: mritd --- modules/caddyhttp/fileserver/caddyfile.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/caddyhttp/fileserver/caddyfile.go b/modules/caddyhttp/fileserver/caddyfile.go index 447f4811c10..9c9cd330f4e 100644 --- a/modules/caddyhttp/fileserver/caddyfile.go +++ b/modules/caddyhttp/fileserver/caddyfile.go @@ -41,6 +41,7 @@ func init() { // browse [] // precompressed // status +// canonical_uris // } // func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) { @@ -111,6 +112,12 @@ func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) return nil, h.ArgErr() } fsrv.StatusCode = caddyhttp.WeakString(h.Val()) + case "canonical_uris": + if !h.NextArg() || h.Val() != "false" { + return nil, h.ArgErr() + } + falseBool := false + fsrv.CanonicalURIs = &falseBool default: return nil, h.Errf("unknown subdirective '%s'", h.Val()) From acb8a033f6801d59ceaf6b0dab95e9ce52b1f60f Mon Sep 17 00:00:00 2001 From: mritd Date: Wed, 30 Jun 2021 10:19:02 +0800 Subject: [PATCH 2/3] feat(file_server): rename subdirective canonical_uris to disable_canonical_uris rename subdirective canonical_uris to disable_canonical_uris Signed-off-by: mritd --- modules/caddyhttp/fileserver/caddyfile.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/caddyhttp/fileserver/caddyfile.go b/modules/caddyhttp/fileserver/caddyfile.go index 9c9cd330f4e..886d6672c37 100644 --- a/modules/caddyhttp/fileserver/caddyfile.go +++ b/modules/caddyhttp/fileserver/caddyfile.go @@ -41,7 +41,7 @@ func init() { // browse [] // precompressed // status -// canonical_uris +// disable_canonical_uris // } // func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) { @@ -112,8 +112,9 @@ func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) return nil, h.ArgErr() } fsrv.StatusCode = caddyhttp.WeakString(h.Val()) - case "canonical_uris": - if !h.NextArg() || h.Val() != "false" { + + case "disable_canonical_uris": + if h.NextArg() { return nil, h.ArgErr() } falseBool := false From 737ead4e3de9b27d64f0b3dbd3e654149719b16c Mon Sep 17 00:00:00 2001 From: mritd Date: Wed, 30 Jun 2021 10:20:55 +0800 Subject: [PATCH 3/3] test(caddyfile_adapt): add disable_canonical_uris subdirective test file add disable_canonical_uris subdirective test file Signed-off-by: mritd --- .../file_server_disable_canonical_uris.txt | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 caddytest/integration/caddyfile_adapt/file_server_disable_canonical_uris.txt diff --git a/caddytest/integration/caddyfile_adapt/file_server_disable_canonical_uris.txt b/caddytest/integration/caddyfile_adapt/file_server_disable_canonical_uris.txt new file mode 100644 index 00000000000..c30b9e95fbf --- /dev/null +++ b/caddytest/integration/caddyfile_adapt/file_server_disable_canonical_uris.txt @@ -0,0 +1,32 @@ +:80 + +file_server { + disable_canonical_uris +} +---------- +{ + "apps": { + "http": { + "servers": { + "srv0": { + "listen": [ + ":80" + ], + "routes": [ + { + "handle": [ + { + "canonical_uris": false, + "handler": "file_server", + "hide": [ + "./Caddyfile" + ] + } + ] + } + ] + } + } + } + } +}