fix: change Validators type, check json body format

This commit is contained in:
buyuxiang
2022-03-01 18:05:13 +08:00
parent c144d14a4e
commit b04a57eb09
7 changed files with 40 additions and 26 deletions

View File

@@ -703,6 +703,15 @@ func (r *caseRunner) runStepRequest(step *TStep) (stepResult *stepData, err erro
if err != nil {
return stepResult, err
}
// check request body format if Content-Type specified as application/json
if strings.HasPrefix(req.Header.Get("Content-Type"), "application/json") {
switch data.(type) {
case bool, float64, string, map[string]interface{}, []interface{}, nil:
break
default:
return stepResult, errors.Errorf("request body type inconsistent with Content-Type: %v", req.Header.Get("Content-Type"))
}
}
requestMap["body"] = data
var dataBytes []byte
switch vv := data.(type) {