pull/137/head
FongMi 3 years ago
parent 414c80b450
commit 04b98c78e9
  1. 12
      quickjs/src/main/java/com/fongmi/quickjs/bean/Req.java
  2. 6
      quickjs/src/main/java/com/fongmi/quickjs/method/Global.java

@ -20,9 +20,9 @@ public class Req {
@SerializedName("method")
private String method;
@SerializedName("body")
private String body;
private JsonElement body;
@SerializedName("data")
private String data;
private JsonElement data;
@SerializedName("headers")
private JsonElement headers;
@ -46,12 +46,12 @@ public class Req {
return TextUtils.isEmpty(method) ? "get" : method;
}
public String getBody() {
return TextUtils.isEmpty(body) ? "" : body.trim();
public JsonElement getBody() {
return body;
}
public String getData() {
return TextUtils.isEmpty(data) ? "" : data.trim();
public JsonElement getData() {
return data;
}
private JsonElement getHeaders() {

@ -161,7 +161,7 @@ public class Global {
timer.schedule(new TimerTask() {
@Override
public void run() {
if (!executor.isShutdown()) executor.submit(() -> { func.call(); });
if (!executor.isShutdown()) executor.submit(() -> {func.call();});
}
}, delay);
}
@ -183,8 +183,8 @@ public class Global {
}
private RequestBody getPostBody(Req req, String contentType) {
if (!req.getData().isEmpty()) return RequestBody.create(req.getData(), MediaType.get("application/json"));
if (!req.getBody().isEmpty() && contentType != null) return RequestBody.create(req.getBody(), MediaType.get(contentType));
if (req.getData() != null) return RequestBody.create(gson.toJson(req.getData()), MediaType.get("application/json"));
if (req.getBody() != null && contentType != null) return RequestBody.create(gson.toJson(req.getBody()), MediaType.get(contentType));
return RequestBody.create("", null);
}

Loading…
Cancel
Save