add CommonRequest.execute
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
package com.imyeyu.network;
|
package com.imyeyu.network;
|
||||||
|
|
||||||
import org.apache.hc.client5.http.fluent.Request;
|
import org.apache.hc.client5.http.fluent.Request;
|
||||||
|
import org.apache.hc.core5.util.Timeout;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -39,4 +40,8 @@ public class CommonRequest {
|
|||||||
public byte[] asBytes() throws IOException {
|
public byte[] asBytes() throws IOException {
|
||||||
return request.execute().returnContent().asBytes();
|
return request.execute().returnContent().asBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void execute() throws IOException {
|
||||||
|
request.execute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,4 +59,12 @@ public class TimiRequest extends GsonRequest {
|
|||||||
}
|
}
|
||||||
return resp.getData();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user