fix SetHeader Replace src header(copy all header in a new http.Header)
This commit is contained in:
parent
0c71408d1f
commit
a6217886dc
21
workflow.go
21
workflow.go
|
@ -41,9 +41,16 @@ func (wf *Workflow) AddHeader(key, value string) *Workflow {
|
|||
return wf
|
||||
}
|
||||
|
||||
// SetHeader 设置头信息 这样构造 []string{value} Get方法从Header参数上获取
|
||||
func (wf *Workflow) SetHeader(key, value string) *Workflow {
|
||||
wf.Header.Set(key, value)
|
||||
// SetHeader 设置完全替换原有Header
|
||||
func (wf *Workflow) SetHeader(header http.Header) *Workflow {
|
||||
wf.Header = make(http.Header)
|
||||
for k, HValues := range header {
|
||||
var newHValues []string
|
||||
for _, value := range HValues {
|
||||
newHValues = append(newHValues, value)
|
||||
}
|
||||
wf.Header[k] = newHValues
|
||||
}
|
||||
return wf
|
||||
}
|
||||
|
||||
|
@ -69,6 +76,14 @@ func (wf *Workflow) AddCookie(c *http.Cookie) *Workflow {
|
|||
return wf
|
||||
}
|
||||
|
||||
// AddCookies 添加[]*http.Cookie
|
||||
func (wf *Workflow) AddCookies(cookies []*http.Cookie) *Workflow {
|
||||
for _, c := range cookies {
|
||||
wf.AddCookie(c)
|
||||
}
|
||||
return wf
|
||||
}
|
||||
|
||||
// AddKVCookie 添加 以 key value 的 Cookie
|
||||
func (wf *Workflow) AddKVCookie(name, value string) *Workflow {
|
||||
wf.Cookies[name] = &http.Cookie{Name: name, Value: value}
|
||||
|
|
Loading…
Reference in New Issue
Block a user