From c51591b308b6e0d97b6ff5f1b3dc842194128698 Mon Sep 17 00:00:00 2001 From: John Rinehart Date: Wed, 28 Mar 2018 15:51:24 -0400 Subject: [PATCH] cmd/syncthing: Set Content-Type header regardless of asset location (#4847) --- cmd/syncthing/gui_statics.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/syncthing/gui_statics.go b/cmd/syncthing/gui_statics.go index b3046b6b8..b54cd9934 100644 --- a/cmd/syncthing/gui_statics.go +++ b/cmd/syncthing/gui_statics.go @@ -89,6 +89,10 @@ func (s *staticsServer) serveAsset(w http.ResponseWriter, r *http.Request) { if s.assetDir != "" { p := filepath.Join(s.assetDir, theme, filepath.FromSlash(file)) if _, err := os.Stat(p); err == nil { + mtype := s.mimeTypeForFile(file) + if len(mtype) != 0 { + w.Header().Set("Content-Type", mtype) + } http.ServeFile(w, r, p) return } @@ -101,6 +105,10 @@ func (s *staticsServer) serveAsset(w http.ResponseWriter, r *http.Request) { if s.assetDir != "" { p := filepath.Join(s.assetDir, config.DefaultTheme, filepath.FromSlash(file)) if _, err := os.Stat(p); err == nil { + mtype := s.mimeTypeForFile(file) + if len(mtype) != 0 { + w.Header().Set("Content-Type", mtype) + } http.ServeFile(w, r, p) return }