react-native/Libraries/Network
grgmo d09cd62011 Add support for ontimeout and onerror handler when using XMLHttpRequest for Android and iOS
Summary:Currently React-Native does not have `ontimeout` and `onerror` handlers for [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest). This is an extension to [No timeout on XMLHttpRequest](https://github.com/facebook/react-native/issues/4648).

With addition to two handlers, both Android and iOS can now handle `ontimeout` if request times out and `onerror` when there is general network error.

**Test plan**

Code has been tested on both Android and iOS with [Charles](https://www.charlesproxy.com/) by setting a breakpoint on the request which fires `ontimeout` when the request waits beyond `timeout` time and `onerror` when there is network error.

**Usage**

JavaScript -

```
var request = new XMLHttpRequest();

function onLoad() {
    console.log(request.status);
};

function onTimeout() {
    console.log('Timeout');
};

function onError() {
    console.log('General network error');
};

request.onload = onLoad;
request.ontimeout = onTimeout;
request.onerr
Closes https://github.com/facebook/react-native/pull/6841

Differential Revision: D3178859

Pulled By: lexs

fb-gh-sync-id: 30674570653e92ab5f7e74bd925dd5640fc862b6
fbshipit-source-id: 30674570653e92ab5f7e74bd925dd5640fc862b6
2016-04-15 05:17:21 -07:00
..
RCTNetwork.xcodeproj Added RCTDataRequestHandler 2015-10-19 09:07:06 -07:00
__tests__ Add support for ontimeout and onerror handler when using XMLHttpRequest for Android and iOS 2016-04-15 05:17:21 -07:00
FormData.js Remove double to string convertion in FormData 2016-04-06 09:01:30 -07:00
NetInfo.js Fix fbsource errors 2016-03-09 16:54:24 -08:00
RCTDataRequestHandler.h Added RCTDataRequestHandler 2015-10-19 09:07:06 -07:00
RCTDataRequestHandler.m Fix retain cyles in RCTNetworkTask when used with RCTFileRequestHandler and RCTDataRequestHandler 2015-11-04 07:16:26 -08:00
RCTFileRequestHandler.h Added RCTFileRequestHandler 2015-10-13 08:14:28 -07:00
RCTFileRequestHandler.m Replaced RCTSparseArray with NSDictionary 2015-11-14 10:28:28 -08:00
RCTHTTPRequestHandler.h Refactored networking logic out into RCTDownloadTask 2015-07-23 04:00:31 -08:00
RCTHTTPRequestHandler.m Refactored module access to allow for lazy loading 2015-11-25 04:49:45 -08:00
RCTNetInfo.h Rename RCTReachability to RCTNetInfo 2015-08-14 08:20:01 -08:00
RCTNetInfo.m getCurrentConnectivity should resolve with object 2016-03-09 16:30:30 -08:00
RCTNetworkTask.h Added throttling on requests made by RCTImageLoader 2016-02-16 12:42:34 -08:00
RCTNetworkTask.m Added throttling on requests made by RCTImageLoader 2016-02-16 12:42:34 -08:00
RCTNetworking.android.js Implement XHR timeout for Android and IOS natively. 2016-01-18 08:10:59 -08:00
RCTNetworking.h Added RCTDataRequestHandler 2015-10-19 09:07:06 -07:00
RCTNetworking.ios.js ensure that RCTNetworking JS function names are consistent with android 2015-11-18 15:48:29 -08:00
RCTNetworking.m Add support for ontimeout and onerror handler when using XMLHttpRequest for Android and iOS 2016-04-15 05:17:21 -07:00
XMLHttpRequest.android.js Implement XHR timeout for Android and IOS natively. 2016-01-18 08:10:59 -08:00
XMLHttpRequest.ios.js Implement XHR timeout for Android and IOS natively. 2016-01-18 08:10:59 -08:00
XMLHttpRequestBase.js Add support for ontimeout and onerror handler when using XMLHttpRequest for Android and iOS 2016-04-15 05:17:21 -07:00