From 6569f7d11459ac24ca649c3f6ca22a58a3153426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sun, 27 Aug 2023 16:06:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=93=8D=E5=BA=94=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=A0=81=E6=8F=90=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- httpclient/request.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/httpclient/request.go b/httpclient/request.go index fca5d8b..e30b64a 100644 --- a/httpclient/request.go +++ b/httpclient/request.go @@ -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() {