feat(request-timeout): set proper timeout for HTTP requests

set connect timeout to 5s
set read and write timeout to 5s
set call timeout to 10s
for image-downloading requests, set call timeout to 0 (no timeout)
This commit is contained in:
qnnnnez committed 2020-09-17 13:31:56 +08:00
1 parent a4859ba2ee
commit 739d338245
2 files changed
+8 -4

No files matched your search

@@ -1219,7 +1219,10 @@ public final class SpiderQueen implements Runnable {
Log.d(TAG, "Start download image " + index);
}
Call call = mHttpClient.newCall(new EhRequestBuilder(targetImageUrl, referer).build());
// disable Call Timeout for image-downloading requests
Call call = mHttpClient.newBuilder()
.callTimeout(0, TimeUnit.SECONDS).build()
.newCall(new EhRequestBuilder(targetImageUrl, referer).build());
Response response = call.execute();
ResponseBody responseBody = response.body();