优化响应状态码提取

This commit is contained in:
白茶清欢 2023-08-27 16:06:44 +08:00
parent 7e71a76959
commit 6569f7d114

View File

@ -290,7 +290,11 @@ func send(apiConfig *ApiRequestConfig, header map[string]string) *ApiResponse {
}
// 提取响应错误码
if response.RequestConfig.ResponseCodeFieldLocation == ResponseCodeFieldLocationHeader {
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() {