Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
ce0988f4
Commit
ce0988f4
authored
Nov 19, 2018
by
Wèi Cōngruì
Committed by
Matt Holt
Nov 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
templates: delete ETag and Last-Modified headers (#2338)
Fixes #1920
parent
1c92557c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
caddyhttp/templates/templates.go
caddyhttp/templates/templates.go
+4
-0
caddyhttp/templates/templates_test.go
caddyhttp/templates/templates_test.go
+10
-0
No files found.
caddyhttp/templates/templates.go
View file @
ce0988f4
...
...
@@ -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"
))
...
...
caddyhttp/templates/templates_test.go
View file @
ce0988f4
...
...
@@ -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
)
}
}
})
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment