add CommonRequest.execute

This commit is contained in:
Timi
2025-11-07 00:16:44 +08:00
parent fbcf21e990
commit a240c00996
2 changed files with 13 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package com.imyeyu.network;
import org.apache.hc.client5.http.fluent.Request;
import org.apache.hc.core5.util.Timeout;
import java.io.IOException;
@ -39,4 +40,8 @@ public class CommonRequest {
public byte[] asBytes() throws IOException {
return request.execute().returnContent().asBytes();
}
public void execute() throws IOException {
request.execute();
}
}

View File

@ -59,4 +59,12 @@ public class TimiRequest extends GsonRequest {
}
return resp.getData();
}
@Override
public void execute() throws IOException {
TimiResponse<?> resp = getGson().fromJson(asJsonObject(), TypeToken.getParameterized(TimiResponse.class, Object.class).getType());
if (resp.isFail()) {
throw resp.toException();
}
}
}