|
|
@@ -4,8 +4,10 @@ import ( |
|
|
|
"encoding/json" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" |
|
|
|
"io/ioutil" |
|
|
|
"net/http" |
|
|
|
"strings" |
|
|
|
) |
|
|
|
|
|
|
|
type AcsResponse interface { |
|
|
@@ -86,12 +88,22 @@ func Unmarshal(response AcsResponse, httpResponse *http.Response, format string) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
if !response.IsSuccess() { |
|
|
|
err = errors.New(fmt.Sprintf("%d %s", response.GetHttpStatus(), response.GetHttpContentString())) |
|
|
|
|
|
|
|
if _, isCommonResponse := response.(CommonResponse); isCommonResponse { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if _, isCommonResponse := response.(CommonResponse); isCommonResponse { |
|
|
|
if !response.IsSuccess() { |
|
|
|
if contentType, ok := response.GetHttpHeaders()["Content-Type"]; ok { |
|
|
|
for _, v := range contentType { |
|
|
|
if strings.Contains(v, requests.Json) { |
|
|
|
json.Unmarshal(response.GetHttpContentBytes(), response) |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
err = errors.New(fmt.Sprintf("%d %s", response.GetHttpStatus(), response.GetHttpContentString())) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|