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
93d982a5
Commit
93d982a5
authored
Apr 03, 2016
by
Pieter Raubenheimer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve readability and fully comply with RFC7232
parent
572b9e4d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
middleware/fileserver.go
middleware/fileserver.go
+2
-2
middleware/fileserver_test.go
middleware/fileserver_test.go
+3
-3
No files found.
middleware/fileserver.go
View file @
93d982a5
...
...
@@ -130,8 +130,8 @@ func (fh *fileHandler) serveFile(w http.ResponseWriter, r *http.Request, name st
}
// Add ETag header
e
:=
fmt
.
Sprintf
(
"
\"
%x-%x
\"
"
,
d
.
ModTime
()
.
Unix
(),
d
.
Size
())
w
.
Header
()
.
Set
(
"E
t
ag"
,
e
)
e
:=
fmt
.
Sprintf
(
`W/"%x-%x"`
,
d
.
ModTime
()
.
Unix
(),
d
.
Size
())
w
.
Header
()
.
Set
(
"E
T
ag"
,
e
)
// Note: Errors generated by ServeContent are written immediately
// to the response. This usually only happens if seeking fails (rare).
...
...
middleware/fileserver_test.go
View file @
93d982a5
...
...
@@ -62,14 +62,14 @@ func TestServeHTTP(t *testing.T) {
url
:
"https://foo/file1.html"
,
expectedStatus
:
http
.
StatusOK
,
expectedBodyContent
:
testFiles
[
"file1.html"
],
expectedEtag
:
"
\"
1e240-13
\"
"
,
expectedEtag
:
`W/"1e240-13"`
,
},
// Test 3 - access folder with index file with trailing slash
{
url
:
"https://foo/dirwithindex/"
,
expectedStatus
:
http
.
StatusOK
,
expectedBodyContent
:
testFiles
[
filepath
.
Join
(
"dirwithindex"
,
"index.html"
)],
expectedEtag
:
"
\"
1e240-20
\"
"
,
expectedEtag
:
`W/"1e240-20"`
,
},
// Test 4 - access folder with index file without trailing slash
{
...
...
@@ -109,7 +109,7 @@ func TestServeHTTP(t *testing.T) {
url
:
"https://foo/dirwithindex/index.html"
,
expectedStatus
:
http
.
StatusOK
,
expectedBodyContent
:
testFiles
[
filepath
.
Join
(
"dirwithindex"
,
"index.html"
)],
expectedEtag
:
"
\"
1e240-20
\"
"
,
expectedEtag
:
`W/"1e240-20"`
,
},
// Test 11 - send a request with query params
{
...
...
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