mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix: httputils show error when resp body is not dict
This commit is contained in:
@@ -279,7 +279,7 @@ func ParseJSONResponse(resp *http.Response, err error, debug bool) (http.Header,
|
||||
}
|
||||
|
||||
var jrbody jsonutils.JSONObject = nil
|
||||
if len(rbody) > 0 {
|
||||
if len(rbody) > 0 && string(rbody[0]) == "{" {
|
||||
var err error
|
||||
jrbody, err = jsonutils.Parse(rbody)
|
||||
if err != nil && debug {
|
||||
@@ -301,6 +301,9 @@ func ParseJSONResponse(resp *http.Response, err error, debug bool) (http.Header,
|
||||
if jrbody == nil {
|
||||
ce.Code = resp.StatusCode
|
||||
ce.Details = resp.Status
|
||||
if len(rbody) > 0 {
|
||||
ce.Details = string(rbody)
|
||||
}
|
||||
return nil, nil, &ce
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user