mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-29 07:03:48 +03:00
parent
1c92557c8b
commit
ce0988f48a
2 changed files with 14 additions and 0 deletions
|
@ -110,6 +110,10 @@ func (t Templates) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error
|
|||
// set the actual content length now that the template was executed
|
||||
w.Header().Set("Content-Length", strconv.Itoa(buf.Len()))
|
||||
|
||||
// delete the headers related to cache
|
||||
w.Header().Del("ETag")
|
||||
w.Header().Del("Last-Modified")
|
||||
|
||||
// get the modification time in preparation for http.ServeContent
|
||||
modTime, _ := time.Parse(http.TimeFormat, w.Header().Get("Last-Modified"))
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ func TestTemplates(t *testing.T) {
|
|||
req string
|
||||
respCode int
|
||||
res string
|
||||
bypass bool
|
||||
}{
|
||||
{
|
||||
tpl: tmpl,
|
||||
|
@ -113,6 +114,7 @@ func TestTemplates(t *testing.T) {
|
|||
respCode: http.StatusOK,
|
||||
res: `<!DOCTYPE html><html><head><title>as it is</title></head><body>{{.Include "header.html"}}</body></html>
|
||||
`,
|
||||
bypass: true,
|
||||
},
|
||||
} {
|
||||
c := c
|
||||
|
@ -135,6 +137,14 @@ func TestTemplates(t *testing.T) {
|
|||
if respBody != c.res {
|
||||
t.Fatalf("Test: the expected body %v is different from the response one: %v", c.res, respBody)
|
||||
}
|
||||
|
||||
if !c.bypass {
|
||||
eTag := rec.Header().Get("ETag")
|
||||
lastModified := rec.Header().Get("Last-Modified")
|
||||
if eTag != "" || lastModified != "" {
|
||||
t.Fatalf("Test: expect a response without ETag or Last-Modified, got %v %v", eTag, lastModified)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue