From f403b6c66d4092f96a25a6b4cef94436f29caa0f Mon Sep 17 00:00:00 2001 From: bayuzhen Date: Wed, 28 Aug 2024 21:48:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E8=AF=B7=E6=B1=82=E6=96=B9ip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/bocloud/sms/service/TrxServiceImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bocloud.sms.service/src/main/java/com/bocloud/sms/service/TrxServiceImpl.java b/bocloud.sms.service/src/main/java/com/bocloud/sms/service/TrxServiceImpl.java index 2deb8ee..ec23661 100644 --- a/bocloud.sms.service/src/main/java/com/bocloud/sms/service/TrxServiceImpl.java +++ b/bocloud.sms.service/src/main/java/com/bocloud/sms/service/TrxServiceImpl.java @@ -64,7 +64,9 @@ public class TrxServiceImpl implements TrxService { try { HttpRequest httpRequest = HttpRequest.get(url) .addHeaders(paramsMap); + httpRequest.cookie("ngx_cookie=" + ngxCookie); log.info("调用天融信获取随机字符串接口, url:" + httpRequest.getUrl() + "请求头:" + JSONObject.toJSONString(httpRequest.headers())); + log.info("调用天融信获取随机字符串接口, 请求信息:" + JSONObject.toJSONString(httpRequest)); HttpResponse response = httpRequest.execute(); result = JSONObject.parseObject(response.body()); if ("-1".equals(result.getString("result"))) { @@ -248,7 +250,8 @@ public class TrxServiceImpl implements TrxService { if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { ip = request.getRemoteAddr(); } - return ip; + String[] parts = ip.split(":"); + return parts[0]; } }