cmd/syncthing: Set Content-Type header regardless of asset location (#4847)

This commit is contained in:
John Rinehart 2018-03-28 15:51:24 -04:00 committed by Jakob Borg
parent 8b052a950d
commit c51591b308
1 changed files with 8 additions and 0 deletions

View File

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