| | |
| | | if (callBack != null) { |
| | | callBack.onSuccess(str); |
| | | // System.out.println("http->回复->" + requestUrl + "\r\n" + gson.fromJson(str, JsonObject.class).toString()); |
| | | System.out.println("http->回复->" + requestUrl + "\r\n" + str); |
| | | HdlLogLogic.print("http->回复->" + requestUrl + "\r\n" + str, true); |
| | | } |
| | | } |
| | | |
| | |
| | | HDLExceptionSubmitUtils.submit(requestUrl, body, e); |
| | | if (callBack != null) { |
| | | callBack.onFailure(e); |
| | | System.out.println("http->回复->" + requestUrl + "\r\n" + "\"{code=\"" + e.getCode() + "," + "\"message=\"" + e.getMsg() + "}"); |
| | | HdlLogLogic.print("http->回复->" + requestUrl + "\r\n" + "\"{code=\"" + e.getCode() + "," + "\"message=\"" + e.getMsg() + "}", true); |
| | | } |
| | | } |
| | | }); |
| | |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | HdlLogLogic.print("http->发送->", fullUrl + "\r\n" + json); |
| | | HdlLogLogic.print("http->发送->" + fullUrl + "\r\n" + json, false); |
| | | OkHttpClient okHttpClient = new OkHttpClient(); |
| | | RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8"), getJson(json)); |
| | | final Request request = new Request.Builder() |
| | |
| | | if (response.isSuccessful()) { |
| | | String s = Objects.requireNonNull(response.body()).string(); |
| | | HttpResponsePack httpResponsePack = new Gson().fromJson(s, HttpResponsePack.class); |
| | | HdlLogLogic.print("http->回复->", response.request().url() + "\r\n" + s); |
| | | HdlLogLogic.print("http->回复->" + response.request().url() + "\r\n" + s, false); |
| | | baseSuccessCallBeak.onSuccess(httpResponsePack); |
| | | |
| | | } else { |
| | |
| | | call.enqueue(new Callback() {//异步 |
| | | @Override |
| | | public void onFailure(@NonNull Call call, @NonNull IOException e) { |
| | | HdlLogLogic.print("http->回复->", "\r\n" + e.getMessage()); |
| | | HdlLogLogic.print("http->回复->" + "\r\n" + e.getMessage(), false); |
| | | } |
| | | |
| | | @Override |
| | |
| | | String s = Objects.requireNonNull(response.body()).string(); |
| | | HttpResponsePack httpResponsePack = new Gson().fromJson(s, HttpResponsePack.class); |
| | | baseSuccessCallBeak.onSuccess(httpResponsePack); |
| | | HdlLogLogic.print("http->回复->", "\r\n" + s); |
| | | HdlLogLogic.print("http->回复->" + "\r\n" + s, false); |
| | | } else { |
| | | baseSuccessCallBeak.onFailure(new HDLException(response.code(), response.message())); |
| | | } |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | baseSuccessCallBeak.onFailure(new HDLException(-100, e.getMessage())); |
| | | HdlLogLogic.print("http->回复->", "\r\n" + e.getMessage()); |
| | | HdlLogLogic.print("http->回复->" + "\r\n" + e.getMessage(), false); |
| | | } |
| | | |
| | | } |