|
@@ -34,6 +34,7 @@ import java.util.HashMap;
|
34
|
34
|
import java.util.concurrent.TimeUnit;
|
35
|
35
|
|
36
|
36
|
import okhttp3.Call;
|
|
37
|
+import okhttp3.ConnectionPool;
|
37
|
38
|
import okhttp3.Headers;
|
38
|
39
|
import okhttp3.Interceptor;
|
39
|
40
|
import okhttp3.MediaType;
|
|
@@ -67,6 +68,7 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
|
67
|
68
|
public static HashMap<String, Call> taskTable = new HashMap<>();
|
68
|
69
|
static HashMap<String, Boolean> progressReport = new HashMap<>();
|
69
|
70
|
static HashMap<String, Boolean> uploadProgressReport = new HashMap<>();
|
|
71
|
+ static ConnectionPool pool = new ConnectionPool(5, 30000, TimeUnit.MILLISECONDS);
|
70
|
72
|
|
71
|
73
|
MediaType contentType = RNFetchBlobConst.MIME_OCTET;
|
72
|
74
|
ReactApplicationContext ctx;
|
|
@@ -303,10 +305,10 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
|
303
|
305
|
});
|
304
|
306
|
|
305
|
307
|
if(options.timeout > 0) {
|
306
|
|
- clientBuilder.connectTimeout(options.timeout, TimeUnit.SECONDS);
|
307
|
|
- clientBuilder.readTimeout(options.timeout, TimeUnit.SECONDS);
|
|
308
|
+ clientBuilder.connectTimeout(options.timeout, TimeUnit.MILLISECONDS);
|
|
309
|
+ clientBuilder.readTimeout(options.timeout, TimeUnit.MILLISECONDS);
|
308
|
310
|
}
|
309
|
|
-
|
|
311
|
+ clientBuilder.connectionPool(pool);
|
310
|
312
|
OkHttpClient client = clientBuilder.build();
|
311
|
313
|
Call call = client.newCall(req);
|
312
|
314
|
taskTable.put(taskId, call);
|