fix mime bug which will make server not recognize filename without dot

newgen v1.0.0rc1
兔子 4 years ago
parent 9e7ad45f06
commit 382badb0cc

@ -55,8 +55,8 @@ func RunHttpServer(listenIp, port, auth, folderPath, certKey, version, indexFile
func (v VtqeHttpServer) httpListen(w http.ResponseWriter, r *http.Request) {
log := starlog.Std.NewFlag()
w.Header().Set("Server", "Vicorique")
w.Header().Set("Powered By", "B612.ME")
w.Header().Set("Server", "Victorique")
w.Header().Set("Powered", "B612.ME")
write401 := func() {
w.Header().Set("WWW-Authenticate", ` Basic realm="Please Enter Passwd"`)
w.WriteHeader(401)
@ -138,7 +138,7 @@ func (v VtqeHttpServer) httpListen(w http.ResponseWriter, r *http.Request) {
}
fpinfo, _ := os.Stat(fullpath)
name := filepath.Base(fullpath)
ext := filepath.Ext(name)[1:]
ext := filepath.Ext(name)
mime := GetMIME(ext)
if mime == "" || v.stopMime {
w.Header().Set("Content-Type", "application/download")

@ -1,6 +1,10 @@
package httpserver
func GetMIME(ext string) string {
if len(ext) == 0 || ext == "." {
return ""
}
ext = ext[1:]
switch ext {
case "123":
return "application/vnd.lotus-1-2-3"

Loading…
Cancel
Save