change prefix; prefix not a array;
This commit is contained in:
parent
23a369677f
commit
137121ee59
20
session.go
20
session.go
|
@ -43,26 +43,16 @@ func (body *Body) IOBody() interface{} {
|
||||||
|
|
||||||
// ContentType 获取ContentType
|
// ContentType 获取ContentType
|
||||||
func (body *Body) ContentType() string {
|
func (body *Body) ContentType() string {
|
||||||
content := body.prefix + ";"
|
content := body.prefix
|
||||||
for kvalue := range body.contentTypes {
|
for kvalue := range body.contentTypes {
|
||||||
content += kvalue + ";"
|
content += kvalue + ";"
|
||||||
}
|
}
|
||||||
return strings.TrimRight(content, ";")
|
return strings.TrimRight(content, ";")
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddPrefix AddPrefix 和 AddContentType的顺序会影响到ContentType()的返回结果
|
// SetPrefix SetPrefix 和 AddContentType的顺序会影响到ContentType()的返回结果
|
||||||
func (body *Body) AddPrefix(ct string) {
|
func (body *Body) SetPrefix(ct string) {
|
||||||
content := body.prefix
|
body.prefix = strings.TrimRight(ct, ";") + ";"
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddContentType 添加 Add Type类型
|
// AddContentType 添加 Add Type类型
|
||||||
|
@ -90,7 +80,7 @@ type IBody interface {
|
||||||
// AppendContent
|
// AppendContent
|
||||||
AddContentType(ct string)
|
AddContentType(ct string)
|
||||||
// AddPrefix 添加 Prefix
|
// AddPrefix 添加 Prefix
|
||||||
AddPrefix(ct string)
|
SetPrefix(ct string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// BasicAuth 帐号认真结构
|
// BasicAuth 帐号认真结构
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package requests
|
package requests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -184,9 +183,9 @@ func (wf *Workflow) SetBody(params ...interface{}) *Workflow {
|
||||||
if plen >= 2 {
|
if plen >= 2 {
|
||||||
t := params[plen-1]
|
t := params[plen-1]
|
||||||
defaultContentType = t.(string)
|
defaultContentType = t.(string)
|
||||||
wf.Body.AddPrefix(defaultContentType)
|
wf.Body.SetPrefix(defaultContentType)
|
||||||
} else {
|
} else {
|
||||||
wf.Body.AddPrefix(defaultContentType)
|
wf.Body.SetPrefix(defaultContentType)
|
||||||
}
|
}
|
||||||
|
|
||||||
if defaultContentType == TypeFormData {
|
if defaultContentType == TypeFormData {
|
||||||
|
@ -211,7 +210,6 @@ func (wf *Workflow) SetBody(params ...interface{}) *Workflow {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Println(wf.Body.ContentType())
|
|
||||||
return wf
|
return wf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user