Implement XHR timeout for Android and IOS natively.

Summary:
Opening this in a separate PR but the discussion can be viewed on #4832.

Basically, this is a native implementation and is a bit more elegant. The consensus on my previous PR was that it should be done natively rather than in JS.

There's now no maximum valid timeout value and a timeout of 0 will never time out.

ontimeout isn't implemented (yet) in this PR.

cc nicklockwood ide philikon
Closes https://github.com/facebook/react-native/pull/5038

Reviewed By: svcscm

Differential Revision: D2838743

Pulled By: nicklockwood

fb-gh-sync-id: 774f864ac35082bf522f7665f4311bd3affbe82c
This commit is contained in:
Alex Roman
2016-01-18 07:47:04 -08:00
committed by facebook-github-bot-8
parent a3706411ab
commit 1303e6d039
7 changed files with 38 additions and 18 deletions

View File

@@ -93,7 +93,8 @@ public class NetworkingModuleTest {
0,
SimpleArray.of(),
null,
true);
true,
0);
ArgumentCaptor<Request> argumentCaptor = ArgumentCaptor.forClass(Request.class);
verify(httpClient).newCall(argumentCaptor.capture());
@@ -122,7 +123,8 @@ public class NetworkingModuleTest {
0,
SimpleArray.from(invalidHeaders),
null,
true);
true,
0);
verifyErrorEmit(emitter, 0);
}
@@ -147,7 +149,8 @@ public class NetworkingModuleTest {
0,
SimpleArray.of(),
body,
true);
true,
0);
verifyErrorEmit(emitter, 0);
}
@@ -202,7 +205,8 @@ public class NetworkingModuleTest {
0,
SimpleArray.of(SimpleArray.of("Content-Type", "text/plain")),
body,
true);
true,
0);
ArgumentCaptor<Request> argumentCaptor = ArgumentCaptor.forClass(Request.class);
verify(httpClient).newCall(argumentCaptor.capture());
@@ -238,7 +242,8 @@ public class NetworkingModuleTest {
0,
SimpleArray.from(headers),
null,
true);
true,
0);
ArgumentCaptor<Request> argumentCaptor = ArgumentCaptor.forClass(Request.class);
verify(httpClient).newCall(argumentCaptor.capture());
Headers requestHeaders = argumentCaptor.getValue().headers();
@@ -284,7 +289,8 @@ public class NetworkingModuleTest {
0,
new SimpleArray(),
body,
true);
true,
0);
// verify url, method, headers
ArgumentCaptor<Request> argumentCaptor = ArgumentCaptor.forClass(Request.class);
@@ -341,7 +347,8 @@ public class NetworkingModuleTest {
0,
SimpleArray.from(headers),
body,
true);
true,
0);
// verify url, method, headers
ArgumentCaptor<Request> argumentCaptor = ArgumentCaptor.forClass(Request.class);
@@ -435,7 +442,8 @@ public class NetworkingModuleTest {
0,
SimpleArray.from(headers),
body,
true);
true,
0);
// verify RequestBodyPart for image
PowerMockito.verifyStatic(times(1));