处理请求方ip

develop
bayuzhen 2024-08-28 21:48:44 +08:00
parent eb321aba7c
commit f403b6c66d
1 changed files with 4 additions and 1 deletions

View File

@ -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];
}
}