优化响应状态码提取

This commit is contained in:
白茶清欢 2023-08-27 16:06:44 +08:00
parent 7e71a76959
commit 6569f7d114
1 changed files with 5 additions and 1 deletions

View File

@ -290,7 +290,11 @@ func send(apiConfig *ApiRequestConfig, header map[string]string) *ApiResponse {
}
// 提取响应错误码
if response.RequestConfig.ResponseCodeFieldLocation == ResponseCodeFieldLocationHeader {
response.Code = response.Response.Header.Get(response.RequestConfig.ResponseCodeField)
if strings.ToLower(response.RequestConfig.ResponseCodeField) == "http_code" {
response.Code = responseHttpCode
} else {
response.Code = response.Response.Header.Get(response.RequestConfig.ResponseCodeField)
}
} else {
businessCode := gjson.GetBytes(responseByte, response.RequestConfig.ResponseCodeField)
if businessCode.Exists() {