|
|
@ -165,24 +165,30 @@ public class HttpClientUtil {
|
|
|
|
.url(url)
|
|
|
|
.url(url)
|
|
|
|
.post(requestBody)
|
|
|
|
.post(requestBody)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
Response resp = hippo4JOkHttpClient.newCall(request).execute();
|
|
|
|
try (Response resp = hippo4JOkHttpClient.newCall(request).execute()) {
|
|
|
|
|
|
|
|
try (ResponseBody responseBody = resp.body()) {
|
|
|
|
if (resp.code() != HTTP_OK_CODE) {
|
|
|
|
if (resp.code() != HTTP_OK_CODE) {
|
|
|
|
String msg = String.format("HttpPost 响应 code 异常. [code] %s [url] %s [body] %s", resp.code(), url, jsonBody);
|
|
|
|
String msg = String.format("HttpPost 响应 code 异常. [code] %s [url] %s [body] %s", resp.code(), url, jsonBody);
|
|
|
|
throw new RuntimeException(msg);
|
|
|
|
throw new ResponseStatusException(HttpStatus.valueOf(resp.code()), msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return resp.body().string();
|
|
|
|
return resp.body().string();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@SneakyThrows
|
|
|
|
@SneakyThrows
|
|
|
|
private byte[] doGet(String url) {
|
|
|
|
private byte[] doGet(String url) {
|
|
|
|
Request request = new Request.Builder().get().url(url).build();
|
|
|
|
Request request = new Request.Builder().get().url(url).build();
|
|
|
|
Response resp = hippo4JOkHttpClient.newCall(request).execute();
|
|
|
|
try(Response resp = hippo4JOkHttpClient.newCall(request).execute()){
|
|
|
|
|
|
|
|
try(ResponseBody responseBody = resp.body()){
|
|
|
|
if (resp.code() != HTTP_OK_CODE) {
|
|
|
|
if (resp.code() != HTTP_OK_CODE) {
|
|
|
|
String msg = String.format("HttpGet 响应 code 异常. [code] %s [url] %s", resp.code(), url);
|
|
|
|
String msg = String.format("HttpGet 响应 code 异常. [code] %s [url] %s", resp.code(), url);
|
|
|
|
throw new RuntimeException(msg);
|
|
|
|
throw new ResponseStatusException(HttpStatus.valueOf(resp.code()), msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return resp.body().bytes();
|
|
|
|
return resp.body().bytes();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@SneakyThrows
|
|
|
|
@SneakyThrows
|
|
|
|
public <T> T restApiGetByThreadPool(String url, Map<String, String> headers, Map<String, String> paramValues, Long readTimeoutMs, Class<T> clazz) {
|
|
|
|
public <T> T restApiGetByThreadPool(String url, Map<String, String> headers, Map<String, String> paramValues, Long readTimeoutMs, Class<T> clazz) {
|
|
|
|