summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgreatroar <61184462+greatroar@users.noreply.github.com>2022-05-22 22:10:18 +0200
committerGitHub <noreply@github.com>2022-05-22 22:10:18 +0200
commit2ca8a5ac61bed74f115fe7ebadd4bbece649df19 (patch)
tree1a525c449374e9fb1ffa1797a33e05f9ffe29b96
parente3078cc531d2f0cba5234f6475c1b3dffe9094d5 (diff)
lib/assets: MIME types, time formats (#8351)v1.20.2-rc.2
.eot and .woff2 weren't listed, but are present in vendored fontawesome. .ttf and .woff are font/* according to IANA, https://www.iana.org/assignments/media-types/media-types.xhtml#font. This matches what mime.TypeByExtension returns. .eot is from https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types. mime.TypeByExtension doesn't recognize this extension. * lib/assets: Use http.ParseTime This understands the three time formats allowed in HTTP.
-rw-r--r--lib/assets/assets.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/assets/assets.go b/lib/assets/assets.go
index eca39e467..2c65012fb 100644
--- a/lib/assets/assets.go
+++ b/lib/assets/assets.go
@@ -44,7 +44,7 @@ func Serve(w http.ResponseWriter, r *http.Request, asset Asset) {
header.Set("ETag", etag)
header.Set("Last-Modified", asset.Modified.Format(http.TimeFormat))
- t, err := time.Parse(http.TimeFormat, r.Header.Get("If-Modified-Since"))
+ t, err := http.ParseTime(r.Header.Get("If-Modified-Since"))
if err == nil && !asset.Modified.After(t) {
w.WriteHeader(http.StatusNotModified)
return
@@ -86,18 +86,22 @@ func MimeTypeForFile(file string) string {
return "text/html; charset=utf-8"
case ".css":
return "text/css; charset=utf-8"
+ case ".eot":
+ return "application/vnd.ms-fontobject"
case ".js":
return "application/javascript; charset=utf-8"
case ".json":
return "application/json; charset=utf-8"
case ".png":
return "image/png"
- case ".ttf":
- return "application/x-font-ttf"
- case ".woff":
- return "application/x-font-woff"
case ".svg":
return "image/svg+xml; charset=utf-8"
+ case ".ttf":
+ return "font/ttf"
+ case ".woff":
+ return "font/woff"
+ case ".woff2":
+ return "font/woff2"
default:
return mime.TypeByExtension(ext)
}