fix mime bug which will make server not recognize filename without dot
This commit is contained in:
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…
x
Reference in New Issue
Block a user