mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-06 00:09:37 +08:00
bugfix: postman empty body options
This commit is contained in:
@@ -29,7 +29,6 @@ var har2caseCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
if flagCount > 1 {
|
if flagCount > 1 {
|
||||||
return errors.New("please specify at most one conversion flag")
|
return errors.New("please specify at most one conversion flag")
|
||||||
|
|
||||||
}
|
}
|
||||||
convert.Run(har2caseOutputType, har2caseOutputDir, har2caseProfilePath, args)
|
convert.Run(har2caseOutputType, har2caseOutputDir, har2caseProfilePath, args)
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -427,14 +427,19 @@ func (s *stepFromPostman) makeRequestBody(item *TItem, steps []*hrp.TStep) error
|
|||||||
func (s *stepFromPostman) makeRequestBodyRaw(item *TItem) (err error) {
|
func (s *stepFromPostman) makeRequestBodyRaw(item *TItem) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if p := recover(); p != nil {
|
if p := recover(); p != nil {
|
||||||
err = fmt.Errorf("make request body raw failed: %v", p)
|
err = fmt.Errorf("make request body (raw) failed: %v", p)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// extract language type
|
// extract language type, default languageType: text
|
||||||
|
languageType := "text"
|
||||||
iOptions := item.Request.Body.Options
|
iOptions := item.Request.Body.Options
|
||||||
iLanguage := iOptions.(map[string]interface{})["raw"]
|
if iOptions != nil {
|
||||||
languageType := iLanguage.(map[string]interface{})["language"].(string)
|
iLanguage := iOptions.(map[string]interface{})["raw"]
|
||||||
|
if iLanguage != nil {
|
||||||
|
languageType = iLanguage.(map[string]interface{})["language"].(string)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// make request body and indicate Content-Type
|
// make request body and indicate Content-Type
|
||||||
rawBody := item.Request.Body.Raw
|
rawBody := item.Request.Body.Raw
|
||||||
@@ -442,7 +447,7 @@ func (s *stepFromPostman) makeRequestBodyRaw(item *TItem) (err error) {
|
|||||||
var iBody interface{}
|
var iBody interface{}
|
||||||
err = json.Unmarshal([]byte(rawBody), &iBody)
|
err = json.Unmarshal([]byte(rawBody), &iBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "make request body raw failed")
|
return errors.Wrap(err, "make request body (raw -> json) failed")
|
||||||
}
|
}
|
||||||
s.Request.Body = iBody
|
s.Request.Body = iBody
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user