|
@@ -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
|
|
|
@@ -72,6 +74,7 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
|
72
|
74
|
|
73
|
75
|
ReactApplicationContext ctx;
|
74
|
76
|
RNFetchBlobConfig options;
|
|
77
|
+ ArrayList<String> redirects = new ArrayList<>();
|
75
|
78
|
String taskId;
|
76
|
79
|
String method;
|
77
|
80
|
String url;
|
|
@@ -280,6 +283,14 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
|
280
|
283
|
|
281
|
284
|
final Request req = builder.build();
|
282
|
285
|
|
|
286
|
+ clientBuilder.addNetworkInterceptor(new Interceptor() {
|
|
287
|
+ @Override
|
|
288
|
+ public Response intercept(Chain chain) throws IOException {
|
|
289
|
+ redirects.add(chain.request().url().toString());
|
|
290
|
+ return chain.proceed(chain.request());
|
|
291
|
+ }
|
|
292
|
+ });
|
|
293
|
+
|
283
|
294
|
// Add request interceptor for upload progress event
|
284
|
295
|
clientBuilder.addInterceptor(new Interceptor() {
|
285
|
296
|
@Override
|
|
@@ -509,6 +520,11 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
|
509
|
520
|
headers.putString(resp.headers().name(i), resp.headers().value(i));
|
510
|
521
|
}
|
511
|
522
|
info.putMap("headers", headers);
|
|
523
|
+ WritableArray redirectList = Arguments.createArray();
|
|
524
|
+ for(String r : redirects) {
|
|
525
|
+ redirectList.pushString(r);
|
|
526
|
+ }
|
|
527
|
+ info.putArray("redirects", redirectList);
|
512
|
528
|
Headers h = resp.headers();
|
513
|
529
|
if(isBlobResp) {
|
514
|
530
|
info.putString("respType", "blob");
|