update 支持Cloudreve任意https的80端口的域名, 修复因json异常解析导致的解析时间超时的问题

This commit is contained in:
QAIU
2024-09-25 20:01:10 +08:00
parent 03fbb3ef15
commit 207b4cf6b3
16 changed files with 87 additions and 52 deletions
@@ -4,6 +4,9 @@ import cn.qaiu.WebClientVertxInit;
import cn.qaiu.entity.ShareLinkInfo;
import io.vertx.core.Handler;
import io.vertx.core.Promise;
import io.vertx.core.json.DecodeException;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.HttpResponse;
import io.vertx.ext.web.client.WebClient;
import io.vertx.ext.web.client.WebClientOptions;
import io.vertx.ext.web.client.WebClientSession;
@@ -98,4 +101,19 @@ public abstract class PanBase {
return t -> fail(this.getClass().getSimpleName() + " - 请求异常 {}: -> {}", errorMsg, t.fillInStackTrace());
}
/**
* bodyAsJsonObject的封装, 会自动处理异常
* @param res HttpResponse
* @return JsonObject
*/
protected JsonObject asJson(HttpResponse<?> res) {
try {
return res.bodyAsJsonObject();
} catch (DecodeException e) {
fail("解析失败: json格式异常: {}", res.bodyAsString());
throw new RuntimeException("解析失败: json格式异常");
}
}
}