diff --git a/session.go b/session.go index af75451..5e4da77 100644 --- a/session.go +++ b/session.go @@ -43,26 +43,16 @@ func (body *Body) IOBody() interface{} { // ContentType 获取ContentType func (body *Body) ContentType() string { - content := body.prefix + ";" + content := body.prefix for kvalue := range body.contentTypes { content += kvalue + ";" } return strings.TrimRight(content, ";") } -// AddPrefix AddPrefix 和 AddContentType的顺序会影响到ContentType()的返回结果 -func (body *Body) AddPrefix(ct string) { - content := body.prefix - for _, v := range strings.Split(ct, ";") { - v = strings.Trim(v, " ") - if v != "" { - if body.prefix != v { - content += v + ";" - } - } - } - content = strings.TrimRight(content, ";") - body.prefix = content +// SetPrefix SetPrefix 和 AddContentType的顺序会影响到ContentType()的返回结果 +func (body *Body) SetPrefix(ct string) { + body.prefix = strings.TrimRight(ct, ";") + ";" } // AddContentType 添加 Add Type类型 @@ -90,7 +80,7 @@ type IBody interface { // AppendContent AddContentType(ct string) // AddPrefix 添加 Prefix - AddPrefix(ct string) + SetPrefix(ct string) } // BasicAuth 帐号认真结构 diff --git a/workflow.go b/workflow.go index bf3235a..1e11136 100644 --- a/workflow.go +++ b/workflow.go @@ -1,7 +1,6 @@ package requests import ( - "log" "net/http" "net/url" "regexp" @@ -184,9 +183,9 @@ func (wf *Workflow) SetBody(params ...interface{}) *Workflow { if plen >= 2 { t := params[plen-1] defaultContentType = t.(string) - wf.Body.AddPrefix(defaultContentType) + wf.Body.SetPrefix(defaultContentType) } else { - wf.Body.AddPrefix(defaultContentType) + wf.Body.SetPrefix(defaultContentType) } if defaultContentType == TypeFormData { @@ -211,7 +210,6 @@ func (wf *Workflow) SetBody(params ...interface{}) *Workflow { } } - log.Println(wf.Body.ContentType()) return wf }