diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-05-13 22:04:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-13 16:04:57 +0200 |
commit | a94a8d0ab1f6c9d63ae607dfec866c47ae3e4b5c (patch) | |
tree | 84c1e5e4f3423ed952b573ab1403844de2951cb7 /modules/public | |
parent | f74501609246646a3ab62b37a1e7469d6fea63b7 (diff) | |
download | gitea-a94a8d0ab1f6c9d63ae607dfec866c47ae3e4b5c.tar.gz gitea-a94a8d0ab1f6c9d63ae607dfec866c47ae3e4b5c.zip |
Use standard HTTP library to serve files (#24693)
`http.ServeFile/ServeContent` handles `If-xxx`, `Content-Length`,
`Range` and `Etag` correctly
After this PR, storage files (eg: avatar) could be responded with
correct Content-Length.
Diffstat (limited to 'modules/public')
-rw-r--r-- | modules/public/public.go | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/modules/public/public.go b/modules/public/public.go index 0c0e6dc1cc..ed38d85cfa 100644 --- a/modules/public/public.go +++ b/modules/public/public.go @@ -97,10 +97,6 @@ func handleRequest(w http.ResponseWriter, req *http.Request, fs http.FileSystem, return true } - if httpcache.HandleFileETagCache(req, w, fi) { - return true - } - serveContent(w, req, fi, fi.ModTime(), f) return true } @@ -124,11 +120,11 @@ func serveContent(w http.ResponseWriter, req *http.Request, fi os.FileInfo, modt w.Header().Set("Content-Type", "application/octet-stream") } w.Header().Set("Content-Encoding", "gzip") - http.ServeContent(w, req, fi.Name(), modtime, rdGzip) + httpcache.ServeContentWithCacheControl(w, req, fi.Name(), modtime, rdGzip) return } } - http.ServeContent(w, req, fi.Name(), modtime, content) + httpcache.ServeContentWithCacheControl(w, req, fi.Name(), modtime, content) return } |