|
@@ -17,6 +17,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
17
|
17
|
import com.facebook.react.bridge.ReadableArray;
|
18
|
18
|
import com.facebook.react.bridge.ReadableMap;
|
19
|
19
|
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
20
|
+import com.facebook.react.bridge.WritableArray;
|
20
|
21
|
import com.facebook.react.bridge.WritableMap;
|
21
|
22
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
22
|
23
|
|
|
@@ -32,6 +33,7 @@ import java.nio.ByteBuffer;
|
32
|
33
|
import java.nio.charset.CharacterCodingException;
|
33
|
34
|
import java.nio.charset.Charset;
|
34
|
35
|
import java.nio.charset.CharsetEncoder;
|
|
36
|
+import java.util.ArrayList;
|
35
|
37
|
import java.util.HashMap;
|
36
|
38
|
import java.util.concurrent.TimeUnit;
|
37
|
39
|
|
|
@@ -87,6 +89,7 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
|
87
|
89
|
ResponseType responseType;
|
88
|
90
|
WritableMap respInfo;
|
89
|
91
|
boolean timeout = false;
|
|
92
|
+ ArrayList<String> redirects = new ArrayList<>();
|
90
|
93
|
|
91
|
94
|
public RNFetchBlobReq(ReadableMap options, String taskId, String method, String url, ReadableMap headers, String body, ReadableArray arrayBody, final Callback callback) {
|
92
|
95
|
this.method = method.toUpperCase();
|
|
@@ -277,7 +280,13 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
|
277
|
280
|
}
|
278
|
281
|
|
279
|
282
|
final Request req = builder.build();
|
280
|
|
-
|
|
283
|
+ clientBuilder.addNetworkInterceptor(new Interceptor() {
|
|
284
|
+ @Override
|
|
285
|
+ public Response intercept(Chain chain) throws IOException {
|
|
286
|
+ redirects.add(chain.request().url().toString());
|
|
287
|
+ return chain.proceed(chain.request());
|
|
288
|
+ }
|
|
289
|
+ });
|
281
|
290
|
// Add request interceptor for upload progress event
|
282
|
291
|
clientBuilder.addInterceptor(new Interceptor() {
|
283
|
292
|
@Override
|
|
@@ -330,6 +339,7 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
|
330
|
339
|
clientBuilder.retryOnConnectionFailure(false);
|
331
|
340
|
clientBuilder.followRedirects(true);
|
332
|
341
|
|
|
342
|
+
|
333
|
343
|
OkHttpClient client = clientBuilder.retryOnConnectionFailure(true).build();
|
334
|
344
|
Call call = client.newCall(req);
|
335
|
345
|
taskTable.put(taskId, call);
|
|
@@ -508,6 +518,11 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
|
508
|
518
|
for(int i =0;i< resp.headers().size();i++) {
|
509
|
519
|
headers.putString(resp.headers().name(i), resp.headers().value(i));
|
510
|
520
|
}
|
|
521
|
+ WritableArray redirectList = Arguments.createArray();
|
|
522
|
+ for(String r : redirects) {
|
|
523
|
+ redirectList.pushString(r);
|
|
524
|
+ }
|
|
525
|
+ info.putArray("redirects", redirectList);
|
511
|
526
|
info.putMap("headers", headers);
|
512
|
527
|
Headers h = resp.headers();
|
513
|
528
|
if(isBlobResp) {
|