diff --git a/workflow.go b/workflow.go index 2029893..a5da8ad 100644 --- a/workflow.go +++ b/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}