Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send a correct Content-Type for device icons #41

Merged
merged 1 commit into from
May 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's okay to call len on a nil slice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, thanks.

if v is nil, len(v) is zero.

w.Header().Set("Ext", strings.TrimPrefix(ext[0], "."))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is what the Ext header is for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "Ext" header is only mentioned here. Looks like it always should be empty, and it is completely unrelated to the file extension.
I set it while debugging issue #40. It just seemed strange to me that the header is empty.
Thank you for removing these lines youself.

}
http.ServeContent(w, r, "", time.Time{}, di.ReadSeeker)
})
}
Expand Down