Commit a7452388 authored by astaxie's avatar astaxie

Merge pull request #1912 from ysqi/issue02

Fixed some bug
parents 520a417c fa741645
...@@ -85,9 +85,11 @@ func initBeforeHTTPRun() { ...@@ -85,9 +85,11 @@ func initBeforeHTTPRun() {
// TestBeegoInit is for test package init // TestBeegoInit is for test package init
func TestBeegoInit(ap string) { func TestBeegoInit(ap string) {
os.Setenv("BEEGO_RUNMODE", "test")
appConfigPath = filepath.Join(ap, "conf", "app.conf") appConfigPath = filepath.Join(ap, "conf", "app.conf")
os.Chdir(ap) os.Chdir(ap)
LoadAppConfig(appConfigProvider, appConfigPath) if err := LoadAppConfig(appConfigProvider, appConfigPath); err != nil {
panic(err)
}
BConfig.RunMode = "test"
initBeforeHTTPRun() initBeforeHTTPRun()
} }
...@@ -274,7 +274,7 @@ func assignConfig(ac config.Configer) error { ...@@ -274,7 +274,7 @@ func assignConfig(ac config.Configer) error {
for adaptor, config := range BConfig.Log.Outputs { for adaptor, config := range BConfig.Log.Outputs {
err := logs.SetLogger(adaptor, config) err := logs.SetLogger(adaptor, config)
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, "%s with the config `%s` got err:%s\n", adaptor, config, err) fmt.Fprintln(os.Stderr, fmt.Sprintf("%s with the config %q got err:%s", adaptor, config, err.Error()))
} }
} }
logs.SetLogFuncCall(BConfig.Log.FileLineNum) logs.SetLogFuncCall(BConfig.Log.FileLineNum)
......
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
"io" "io"
"mime" "mime"
"net/http" "net/http"
"net/url"
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
...@@ -244,13 +245,15 @@ func (output *BeegoOutput) Download(file string, filename ...string) { ...@@ -244,13 +245,15 @@ func (output *BeegoOutput) Download(file string, filename ...string) {
return return
} }
output.Header("Content-Description", "File Transfer") var fName string
output.Header("Content-Type", "application/octet-stream")
if len(filename) > 0 && filename[0] != "" { if len(filename) > 0 && filename[0] != "" {
output.Header("Content-Disposition", "attachment; filename="+filename[0]) fName = filename[0]
} else { } else {
output.Header("Content-Disposition", "attachment; filename="+filepath.Base(file)) fName = filepath.Base(file)
} }
output.Header("Content-Disposition", "attachment; filename="+url.QueryEscape(fName))
output.Header("Content-Description", "File Transfer")
output.Header("Content-Type", "application/octet-stream")
output.Header("Content-Transfer-Encoding", "binary") output.Header("Content-Transfer-Encoding", "binary")
output.Header("Expires", "0") output.Header("Expires", "0")
output.Header("Cache-Control", "must-revalidate") output.Header("Cache-Control", "must-revalidate")
......
...@@ -132,17 +132,13 @@ func NewManager(provideName, config string) (*Manager, error) { ...@@ -132,17 +132,13 @@ func NewManager(provideName, config string) (*Manager, error) {
if cf.EnableSidInHttpHeader { if cf.EnableSidInHttpHeader {
if cf.SessionNameInHttpHeader == "" { if cf.SessionNameInHttpHeader == "" {
err = errors.New("SessionNameInHttpHeader is empty") panic(errors.New("SessionNameInHttpHeader is empty"))
panic(err)
return nil, err
} }
strMimeHeader := textproto.CanonicalMIMEHeaderKey(cf.SessionNameInHttpHeader) strMimeHeader := textproto.CanonicalMIMEHeaderKey(cf.SessionNameInHttpHeader)
if cf.SessionNameInHttpHeader != strMimeHeader { if cf.SessionNameInHttpHeader != strMimeHeader {
strErrMsg := "SessionNameInHttpHeader (" + cf.SessionNameInHttpHeader + ") has the wrong format, it should be like this : " + strMimeHeader strErrMsg := "SessionNameInHttpHeader (" + cf.SessionNameInHttpHeader + ") has the wrong format, it should be like this : " + strMimeHeader
err = errors.New(strErrMsg) panic(errors.New(strErrMsg))
panic(err)
return nil, err
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment