#502 Fix url too long problem.

This commit is contained in:
nkorange 2019-03-17 15:36:51 +08:00
parent 7ca6143550
commit df7278a846
3 changed files with 14 additions and 5 deletions

View File

@ -31,6 +31,7 @@ import com.alibaba.nacos.naming.misc.UtilsAndCommons;
import com.alibaba.nacos.naming.selector.LabelSelector;
import com.alibaba.nacos.naming.selector.NoneSelector;
import com.alibaba.nacos.naming.selector.Selector;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -39,6 +40,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.*;
@ -299,10 +301,15 @@ public class ServiceController {
}
@RequestMapping(value = "/status", method = RequestMethod.POST)
public String serviceStatus(HttpServletRequest request) {
public String serviceStatus(HttpServletRequest request) throws IOException {
String entity = IOUtils.toString(request.getInputStream(), "UTF-8");
String value = URLDecoder.decode(entity, "UTF-8");
JSONObject json = JSON.parseObject(value);
//format: service1@@checksum@@@service2@@checksum
String statuses = WebUtils.required(request, "statuses");
String serverIP = WebUtils.optional(request, "clientIP", "");
String statuses = json.getString("statuses");
String serverIP = json.getString("clientIP");
if (!serverListManager.contains(serverIP)) {
throw new IllegalArgumentException("ip: " + serverIP + " is not in serverlist");

View File

@ -25,6 +25,7 @@ import java.math.BigInteger;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -40,7 +41,7 @@ public class Instances implements Record {
private long lastCalculateTime = 0L;
private List<Instance> instanceList;
private List<Instance> instanceList = new ArrayList<>();
public List<Instance> getInstanceList() {
return instanceList;

View File

@ -15,6 +15,7 @@
*/
package com.alibaba.nacos.naming.misc;
import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.naming.boot.RunningConfig;
import com.ning.http.client.AsyncCompletionHandler;
import com.ning.http.client.Response;
@ -49,7 +50,7 @@ public class ServiceStatusSynchronizer implements Synchronizer {
}
try {
HttpClient.asyncHttpPost(url, null, params, new AsyncCompletionHandler() {
HttpClient.asyncHttpPostLarge(url, null, JSON.toJSONString(params), new AsyncCompletionHandler() {
@Override
public Integer onCompleted(Response response) throws Exception {
if (response.getStatusCode() != HttpURLConnection.HTTP_OK) {