mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-03 19:17:29 -05:00 
			
		
		
		
	Improve readability and fully comply with RFC7232
This commit is contained in:
		
							parent
							
								
									572b9e4d67
								
							
						
					
					
						commit
						93d982a5a4
					
				@ -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).
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
		{
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user