This commit is contained in:
huangsimin 2018-10-23 17:20:17 +08:00
parent 9750935138
commit 4eb213aa6d

View File

@ -194,17 +194,8 @@ func (wf *Workflow) SetBodyParams(params ...interface{}) *Workflow {
return wf
}
// Execute 执行
func (wf *Workflow) Execute() (*Response, error) {
req := buildBodyRequest(wf.Method, wf.GetStringURL(), wf.Body)
if wf.Cookies != nil {
for _, c := range wf.Cookies {
req.AddCookie(c)
}
}
// setHeaderRequest 设置request的头
func setHeaderRequest(req *http.Request, wf *Workflow) {
set := make(map[string]map[string]int)
for key, values := range wf.session.Header {
for _, v := range values {
@ -233,6 +224,25 @@ func (wf *Workflow) Execute() (*Response, error) {
}
}
}
// setHeaderRequest 设置request的临时Cookie, 永久需要在session上设置cookie
func setTempCookieRequest(req *http.Request, wf *Workflow) {
if wf.Cookies != nil {
for _, c := range wf.Cookies {
req.AddCookie(c)
}
}
}
// Execute 执行
func (wf *Workflow) Execute() (*Response, error) {
req := buildBodyRequest(wf.Method, wf.GetStringURL(), wf.Body)
setHeaderRequest(req, wf)
setTempCookieRequest(req, wf)
resp, err := wf.session.client.Do(req)
if err != nil {
return nil, err