summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorMohammed Al Sahaf <[email protected]>2024-04-18 23:31:00 +0300
committerGitHub <[email protected]>2024-04-18 20:31:00 +0000
commitc6673ad4d8c3253179d697f06aac458e48e56546 (patch)
tree45ee4638989a6e591c0d21d55d3d174f31013ea3 /modules
parent9ab09433deba62f9f2b37d824570926f7ee69312 (diff)
downloadcaddy-c6673ad4d8c3253179d697f06aac458e48e56546.tar.gz
caddy-c6673ad4d8c3253179d697f06aac458e48e56546.zip
staticresp: Use the evaluated response body for sniffing JSON content-type (#6249)
Diffstat (limited to 'modules')
-rw-r--r--modules/caddyhttp/staticresp.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/modules/caddyhttp/staticresp.go b/modules/caddyhttp/staticresp.go
index 3ec76f29f..1fea6978f 100644
--- a/modules/caddyhttp/staticresp.go
+++ b/modules/caddyhttp/staticresp.go
@@ -206,7 +206,7 @@ func (s StaticResponse) ServeHTTP(w http.ResponseWriter, r *http.Request, next H
// or for clients to render JSON properly which is very common)
body := repl.ReplaceKnown(s.Body, "")
if body != "" && w.Header().Get("Content-Type") == "" {
- content := strings.TrimSpace(s.Body)
+ content := strings.TrimSpace(body)
if len(content) > 2 &&
(content[0] == '{' && content[len(content)-1] == '}' ||
(content[0] == '[' && content[len(content)-1] == ']')) &&