Skip to content

Commit

Permalink
Merge pull request #41 from h31/device-icon-headers
Browse files Browse the repository at this point in the history
Send a correct Content-Type for device icons
  • Loading branch information
anacrolix authored May 28, 2017
2 parents a1284c8 + 13665f1 commit 6274787
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dlna/dms/dms.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,11 @@ func (server *Server) initMux(mux *http.ServeMux) {
mux.HandleFunc("/debug/pprof/", pprof.Index)
for i, di := range server.Icons {
mux.HandleFunc(fmt.Sprintf("%s/%d", deviceIconPath, i), func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", di.Mimetype)
ext, _ := mime.ExtensionsByType(di.Mimetype)
if ext != nil && len(ext) > 0 {
w.Header().Set("Ext", strings.TrimPrefix(ext[0], "."))
}
http.ServeContent(w, r, "", time.Time{}, di.ReadSeeker)
})
}
Expand Down

0 comments on commit 6274787

Please sign in to comment.