Merge pull request #1602 from test-instructor/fix_hooks

fix: dump request headers and params in hooks
This commit is contained in:
debugtalk
2023-04-24 21:20:08 +08:00
committed by GitHub
+13 -4
View File
@@ -363,10 +363,19 @@ func runStepRequest(r *SessionRunner, step *TStep) (stepResult *StepResult, err
rb.req.ContentLength = int64(len(body)) rb.req.ContentLength = int64(len(body))
} }
} }
headers, ok := rb.requestMap["headers"].(map[string]string) requestParams, ok := rb.requestMap["params"].(map[string]interface{})
rb.req.Header = map[string][]string{} if ok {
for key, value := range headers { params, err := json.Marshal(requestParams)
rb.req.Header.Set(key, value) if err == nil {
rb.req.URL.RawQuery = string(params)
}
}
requestHeaders, ok := rb.requestMap["headers"].(map[string]interface{})
if ok {
rb.req.Header = http.Header{}
for k, v := range requestHeaders {
rb.req.Header.Set(k, v.(string))
}
} }
} }