http: don't expose error

This commit is contained in:
Equim 2017-10-13 12:13:08 +08:00
parent c38b146e69
commit 77119ed3a2

View File

@ -25,16 +25,13 @@ func Handler(m *fm.FileManager) http.Handler {
if code >= 400 { if code >= 400 {
w.WriteHeader(code) w.WriteHeader(code)
if err == nil {
txt := http.StatusText(code) txt := http.StatusText(code)
log.Printf("%v: %v %v\n", r.URL.Path, code, txt) log.Printf("%v: %v %v\n", r.URL.Path, code, txt)
w.Write([]byte(txt)) w.Write([]byte(txt + "\n"))
}
} }
if err != nil { if err != nil {
log.Print(err) log.Print(err)
w.Write([]byte(err.Error()))
} }
}) })
} }