0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00

Improve readability and fully comply with RFC7232

This commit is contained in:
Pieter Raubenheimer 2016-04-03 20:14:10 +01:00
parent 572b9e4d67
commit 93d982a5a4
2 changed files with 5 additions and 5 deletions

View file

@ -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("Etag", e)
e := fmt.Sprintf(`W/"%x-%x"`, d.ModTime().Unix(), d.Size())
w.Header().Set("ETag", e)
// Note: Errors generated by ServeContent are written immediately
// to the response. This usually only happens if seeking fails (rare).

View file

@ -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
{