#2237 1. use ByteArrayEntity 2. getDeclaredMethods

This commit is contained in:
rushsky518 2020-01-10 17:50:17 +08:00
parent 0ed8e6f812
commit 0d304c0b7d
2 changed files with 7 additions and 8 deletions

View File

@ -31,6 +31,7 @@ import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
@ -316,18 +317,16 @@ public class HttpClient {
public static HttpResult httpPutLarge(String url, Map<String, String> headers, byte[] content) {
try {
HttpClientBuilder builder = HttpClients.custom();
builder.setUserAgent(UtilsAndCommons.SERVER_VERSION);
builder.setConnectionTimeToLive(500, TimeUnit.MILLISECONDS);
HttpClientBuilder builder = HttpClients.custom()
.setUserAgent(UtilsAndCommons.SERVER_VERSION)
.setConnectionTimeToLive(500, TimeUnit.MILLISECONDS);
CloseableHttpClient httpClient = builder.build();
HttpPut httpPut = new HttpPut(url);
HttpPut httpPut = new HttpPut(url);
for (Map.Entry<String, String> entry : headers.entrySet()) {
httpPut.setHeader(entry.getKey(), entry.getValue());
}
httpPut.setEntity(new StringEntity(new String(content, StandardCharsets.UTF_8), ContentType.create("application/json", StandardCharsets.UTF_8)));
httpPut.setEntity(new ByteArrayEntity(content, ContentType.APPLICATION_JSON));
HttpResponse response = httpClient.execute(httpPut);
HttpEntity entity = response.getEntity();

View File

@ -58,7 +58,7 @@ public class FilterBase {
private void initClassMethod(Class<?> clazz) {
RequestMapping requestMapping = clazz.getAnnotation(RequestMapping.class);
String classPath = requestMapping.value()[0];
for (Method method : clazz.getMethods()) {
for (Method method : clazz.getDeclaredMethods()) {
if (!method.isAnnotationPresent(RequestMapping.class)) {
parseSubAnnotations(method, classPath);
continue;