use of com.reprezen.kaizen.oasparser.model3.RequestBody in project micronaut-kubernetes by micronaut-projects.
the class OkHttpClientLogging method intercept.
@NonNull
@Override
public Response intercept(@NonNull Chain chain) throws IOException {
Request request = chain.request();
Connection connection = chain.connection();
if (LOG.isTraceEnabled()) {
try {
String method = request.method();
RequestBody requestBody = request.body();
Headers headers = request.headers();
LOG.trace("--> {} {} {} {}-byte body", method, request.url(), (connection != null ? connection.protocol() : ""), (requestBody != null ? requestBody.contentLength() : "0"));
// log headers for trace
for (int i = 0; i < headers.size(); i++) {
LOG.trace("{}: {}", headers.name(i), headers.value(i));
}
} catch (Exception e) {
LOG.warn("Failed to generate OkHttpClient request log: " + e.getMessage(), e);
}
}
Response response = null;
try {
response = chain.proceed(request);
} catch (Exception e) {
if (LOG.isErrorEnabled()) {
LOG.error("HTTP FAILED: " + e.getMessage(), e);
}
throw e;
}
if (LOG.isDebugEnabled()) {
try {
ResponseBody responseBody = response.body();
long contentLength = responseBody.contentLength();
String contentLengthString = contentLength == -1L ? "unknown-length" : String.format("%s-byte", contentLength);
Headers headers = response.headers();
if (LOG.isTraceEnabled()) {
LOG.trace("<-- {} {} {} {}", response.code(), response.message(), response.request().url(), contentLengthString);
for (int i = 0; i < headers.size(); i++) {
LOG.trace("{}: {}", headers.name(i), headers.value(i));
}
} else {
String method = request.method();
RequestBody requestBody = request.body();
LOG.debug("KubeApi {} {} {} OUT<{}-byte> IN <{}> {}", method, request.url(), (connection != null ? connection.protocol() : ""), (requestBody != null ? requestBody.contentLength() : "0"), contentLengthString, response.code());
}
} catch (Exception e) {
if (LOG.isWarnEnabled()) {
LOG.warn("Failed to generate OkHttpClient Response log: " + e.getMessage(), e);
}
}
}
return response;
}
use of com.reprezen.kaizen.oasparser.model3.RequestBody in project C3 by Hi5App.
the class HttpUtilsSoma method getPotentialLocationWithOkHttp.
public static void getPotentialLocationWithOkHttp(JSONObject userInfo, Callback callback) {
try {
RequestBody body = RequestBody.create(JSON, String.valueOf(new JSONObject().put("user", userInfo)));
asyncPostRequest(URL_GET_POTENTIAL_LOCATION, body, callback);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.reprezen.kaizen.oasparser.model3.RequestBody in project C3 by Hi5App.
the class HttpUtilsUser method loginWithOkHttp.
/* 登录 异步方法 */
public static void loginWithOkHttp(JSONObject userInfo, Callback callback) {
try {
RequestBody body = RequestBody.create(JSON, String.valueOf(new JSONObject().put("user", userInfo)));
asyncPostRequest(URL_LOGIN, body, callback);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.reprezen.kaizen.oasparser.model3.RequestBody in project C3 by Hi5App.
the class HttpUtilsUserPerformance method getUserPerformance.
public static void getUserPerformance(JSONObject userInfo, Callback callback) {
try {
RequestBody body = RequestBody.create(JSON, String.valueOf(new JSONObject().put("user", userInfo)));
asyncPostRequest(URL_SOMA_COUNT, body, callback);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.reprezen.kaizen.oasparser.model3.RequestBody in project C3 by Hi5App.
the class HttpUtilsCheck method checkWithOkHttp.
public static void checkWithOkHttp(String arborname, String username, String password, String owner, int result, Callback callback) {
try {
RequestBody body = RequestBody.create(JSON, String.valueOf(new JSONObject().put("arborname", arborname).put("name", username).put("password", password).put("owner", owner).put("result", result)));
asyncPostRequest(URL_CHECK, body, callback);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations