serve text/plain content with charset=utf-8 header
This commit is contained in:
parent
c958c57794
commit
524f37d9fe
12
download.go
12
download.go
@ -37,9 +37,17 @@ func (this *Server) handleViewInternal(w http.ResponseWriter, r *http.Request, f
|
|||||||
|
|
||||||
// ServeContent only uses the filename to get the mime type, which we can
|
// ServeContent only uses the filename to get the mime type, which we can
|
||||||
// set accurately (including blacklist)
|
// set accurately (including blacklist)
|
||||||
w.Header().Set(`Content-Type`, m.MimeType)
|
|
||||||
if m.MimeType == `application/octet-stream` {
|
switch m.MimeType {
|
||||||
|
case `text/plain`:
|
||||||
|
w.Header().Set(`Content-Type`, `text/plain; charset=UTF-8`)
|
||||||
|
|
||||||
|
case `application/octet-stream`:
|
||||||
|
w.Header().Set(`Content-Type`, m.MimeType)
|
||||||
w.Header().Set(`Content-Disposition`, `attachment; filename="`+m.Filename+`"`)
|
w.Header().Set(`Content-Disposition`, `attachment; filename="`+m.Filename+`"`)
|
||||||
|
|
||||||
|
default:
|
||||||
|
w.Header().Set(`Content-Type`, m.MimeType)
|
||||||
}
|
}
|
||||||
|
|
||||||
http.ServeContent(w, r, "", m.UploadTime, f)
|
http.ServeContent(w, r, "", m.UploadTime, f)
|
||||||
|
Loading…
Reference in New Issue
Block a user