diff --git a/naming/src/main/java/com/alibaba/nacos/naming/misc/HttpClient.java b/naming/src/main/java/com/alibaba/nacos/naming/misc/HttpClient.java index de3f2c2a1fa..492a6c5fad0 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/misc/HttpClient.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/misc/HttpClient.java @@ -99,7 +99,7 @@ public static HttpResult request(String url, List headers, Map headers, Map 0 && headerElements[0] != null && - headerElements[0].getParameterByName("charset") != null) { + headerElements[0].getParameterByName("charset") != null) { charset = headerElements[0].getParameterByName("charset").getValue(); } } @@ -392,7 +392,7 @@ public static HttpResult httpPostLarge(String url, Map headers, String charset = headerElements[0].getParameterByName("charset").getValue(); return new HttpResult(response.getStatusLine().getStatusCode(), - IoUtils.toString(entity.getContent(), charset), Collections.emptyMap()); + IoUtils.toString(entity.getContent(), charset), Collections.emptyMap()); } catch (Exception e) { return new HttpResult(500, e.toString(), Collections.emptyMap()); } @@ -453,14 +453,14 @@ private static void setHeaders(HttpURLConnection conn, List headers, Str } conn.addRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" - + encoding); + + encoding); conn.addRequestProperty("Accept-Charset", encoding); conn.addRequestProperty(HttpHeaderConsts.CLIENT_VERSION_HEADER, VersionUtils.VERSION); conn.addRequestProperty(HttpHeaderConsts.USER_AGENT_HEADER, UtilsAndCommons.SERVER_VERSION); } public static String encodingParams(Map params, String encoding) - throws UnsupportedEncodingException { + throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder(); if (null == params || params.isEmpty()) { return null; diff --git a/naming/src/main/java/com/alibaba/nacos/naming/web/DistroFilter.java b/naming/src/main/java/com/alibaba/nacos/naming/web/DistroFilter.java index 5eddc5373f2..365d9adb9b4 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/web/DistroFilter.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/web/DistroFilter.java @@ -39,7 +39,6 @@ import java.security.AccessControlException; import java.util.ArrayList; import java.util.Enumeration; -import java.util.HashMap; import java.util.List; /** @@ -124,9 +123,9 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo String body = IoUtils.toString(req.getInputStream(), Charsets.UTF_8.name()); HttpClient.HttpResult result = - HttpClient.request("http://" + distroMapper.mapSrv(groupedServiceName) + urlString, headerList, - StringUtils.isBlank(req.getQueryString()) ? HttpClient.translateParameterMap(req.getParameterMap()) : new HashMap<>(2) - , body, PROXY_CONNECT_TIMEOUT, PROXY_READ_TIMEOUT, Charsets.UTF_8.name(), req.getMethod()); + HttpClient.request("http://" + distroMapper.mapSrv(groupedServiceName) + req.getRequestURI(), headerList, + HttpClient.translateParameterMap(req.getParameterMap()), + body, PROXY_CONNECT_TIMEOUT, PROXY_READ_TIMEOUT, Charsets.UTF_8.name(), req.getMethod()); try { resp.setCharacterEncoding("UTF-8");