Commit Graph

200 Commits

Author SHA1 Message Date
Nick Lockwood 5263b23321 Renamed RCTDataManager to RCTNetworking 2015-06-18 09:44:30 -08:00
Tadeu Zagallo 58c58d9bed [ReactNative] Fix racing condition on RKHTTPRequestHandler 2015-06-15 11:24:42 -08:00
Nick Lockwood 650fc9de4c Increased warning levels to -Wall -Wextra, and fixed Xcode 7 beta issues
Summary:
@public

I've increased the warning levels in the OSS frameworks, which caught a bunch of minor issues. I also fixed some new errors in Xcode 7 relating to designated initializers and TLS security.

Test Plan:
* Test the sample apps and make sure they still work.
* Run tests.
2015-06-15 07:52:50 -08:00
Eric Vicenti 32f895a315 [ReactNative] NetInfo listener Map 2015-06-12 14:56:21 -08:00
Tadeu Zagallo 2a7adfb815 [ReactNative] Use RCTNullIfNill and (id)kCFNull
Summary:
@public

Use consistent `null` handling:

`value || null`                ->  `RCTNullIfNil(value)`
`value == null ? nil : value`  ->  `RCTNilIfNull(value)`
`[NSNull null]`                ->  `(id)kCFNull`

Test Plan: The tests should be enough.
2015-06-12 11:03:10 -08:00
Tadeu Zagallo dcf15f84dc [ReactNative] Fix racing condition on RCTDataManager 2015-06-11 10:44:05 -08:00
Nick Lockwood 2ee8410a71 Removed nullability attributes until Infer supports them 2015-06-11 10:39:29 -08:00
Gabe Levi b05e99a531 [Flow] Fix or suppress react-native github errors for Flow v0.12.0 2015-06-10 13:34:19 -08:00
Nick Lockwood f88bc3eb73 [ReactNative] Refactor RCTDataManager to support pluggable data source modules (RCTURLRequestHandlers)
Summary:
@public

This is a refactor of @philikon's original diff that decouples the dependencies between the Network and Image modules, and replaces RCTDataQueryExecutor with a more useful abstraction.

I've introduced the RCTURLRequestHandler protocol, which is a new type of bridge module used for loading data using an NSURLRequest. RCTURLRequestHandlers can be registered using RCT_EXPORT_MODULE() and are then available at runtime for use by the RCTDataManager, which will automatically select the appropriate handler for a given request based on the handler's self-reported capabilities.

The currently implemented handlers are:

- RCTHTTPRequestHandler - the standard open source HTTP request handler that uses NSURLSession
- RKHTTPRequestHandler - the internal FB HTTP request handler that uses FBNetworking
- RCTImageRequestHandler - a handler for loading local images from the iOS asset-library

Depends on D2108193

Test Plan:
- Internal apps still work
- OSS port still compiles, Movies app and a sample Parse app still work
- uploading image to Parse using the above code snippet works
- tested `FormData` with string and image parameters using http://www.posttestserver.com/
2015-06-09 12:27:06 -08:00
Nick Lockwood f4bf80f3ea [ReactNative] Allow uploading native files (e.g. photos) and FormData via XMLHttpRequest 2015-06-09 12:27:05 -08:00
Christopher Chedeau 8ee9bfe944 [ReactNative] Fix XHR 2015-06-06 16:44:55 -08:00
Nick Lockwood 96c070de11 Fixed typo in XMLHttpRequest.ios.js 2015-06-05 18:47:18 -08:00
Nick Lockwood e00b9ac8f3 Added incremental XMLHttpRequest updates
Summary:
@public

Previously, our XMLHttpRequest implementation would only update the readyState when the download was fully completed. This diff adds support for receiving incremental data updates as the download happens, which can be monitored by adding the onreadystatechange event handler.

As a performance optimization, incremental data updates are only sent if the onreadystatechanged handler has been set in the JS, otherwise it just sends the whole data block once download is complete, as before.

Test Plan:
* Run the UIExplorer XMLHttpRequest example (in both OSS and Catalyst) to see incremental downloads working.
* Run the Movies app to see regular (non-incremental) downloads in action
* Run any network-based app in Catalyst shell to verify RKDataManager still works
2015-06-05 15:21:25 -08:00
Nick Lockwood 10b13512b9 Simplify RKDataManager 2015-06-03 05:36:25 -08:00
Andrei Coman 0aa7f3f8d5 [react_native] Implement connectivity module 2015-06-02 05:41:16 -08:00
Nick Lockwood a2db4a4a5b Removed redundant JSON encode/decode from RCTDataManager
Summary:
@public

For some reason we were manually JSON-encoding the RCTDataManager responses, and then decoding them again on the JS side. Since all data sent over the bridge is JSON-encoded anyway, this is pretty pointless.

Test Plan:
* Test Movies app in OSS, which uses RCTDataManager
* Test any code that uses RKHTTPQueryGenericExecutor to make network requests (e.g. Groups)
* Test the Groups photo upload feature, which uses RKHTTPQueryWithImageUploadExecutor
2015-06-01 08:35:56 -08:00
Philipp von Weitershausen 3269af227f Back out D2098670: Allow uploading a native file (e.g. photo) via XMLHttpRequest 2015-05-26 12:50:25 -08:00
Philipp von Weitershausen 4273af9e29 Allow uploading a native file (e.g. photo) via XMLHttpRequest
Summary:
With this in place, it's possible to upload a picture from the `CameraRoll` to Parse, for instance:

    xhr = new XMLHttpRequest();
    xhr.onload = function() {
      data = JSON.parse(xhr.responseText);
      var parseFile = new Parse.File(data.name);
      parseFile._url = data.url;
      callback(parseFile);
    };
    xhr.setRequestHeader('X-Parse-Application-Id', appID);
    xhr.setRequestHeader('X-Parse-JavaScript-Key', appKey);
    xhr.open('POST', 'https://api.parse.com/1/files/image.jpg');
    // assetURI as provided e.g. by the CameraRoll API
    xhr.send(new NativeFile(assetURI));

Closes https://github.com/facebook/react-native/pull/1357
Github Author: Philipp von Weitershausen <philikon@fb.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-26 09:45:34 -08:00
Philipp von Weitershausen 7069e4cd3f XMLHttpRequest: ignore case for request headers
Summary:
HTTP headers are case-insensitive, so we should treat them that way when they're being set on `XMLHttpRequest`.
Closes https://github.com/facebook/react-native/pull/1381
Github Author: Philipp von Weitershausen <philikon@fb.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-26 08:15:42 -08:00
Philipp von Weitershausen c6ed85afcc new XMLHttpRequest().status is a number, not a string
Summary:
See http://www.w3.org/TR/XMLHttpRequest/#interface-xmlhttprequest
Closes https://github.com/facebook/react-native/pull/1356
Github Author: Philipp von Weitershausen <philikon@fb.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-22 16:42:15 -08:00
Ryan Pastorelle 8a74a9f7c3 Force `responseHeaders` to lower case to respect case-insensitivity
Summary:
`XMLHttpRequest.getResponseHeader` is case-insensitive, therefor the React-Native implementation needs to mimic this behavior as to not break libraries that are dependent on this.

There is a corresponding issue in `superagent` but this is the root cause (https://github.com/visionmedia/superagent/issues/636).
Closes https://github.com/facebook/react-native/pull/1138
Github Author: Ryan Pastorelle <rpastorelle@yahoo.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-05 14:09:40 -08:00
Nick Lockwood 48297753cf Refactored RKSounds, moved it into it's own library, and fixed tests 2015-04-28 10:53:53 -08:00
Nick Lockwood bc24be8584 Fixed nil object insertion crash due to incorrectly encoded HTTP response body data 2015-04-28 04:48:32 -08:00
Tadeu Zagallo d293bed5ab [ReactNative] Fix analyze errors on oss 2015-04-24 08:28:35 -08:00
Andy Street eafe93096c [react_native] JS files from D2012956: [react_native] Never return null from XHR.getAllResponseHeaders if request has completed 2015-04-22 09:05:42 -08:00
Josh Zana 368e507b38 Implement XmlHttpRequestBase#getAllResponseHeaders and getResponseHeader
Summary:
Used https://github.com/facebook/react-native/pull/382 as inspiration
but modified to return null instead of undefined as per the spec at
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest

This unblocks use of Dropbox.js within a react-native app, as well
as any other libraries that make use of these methods in XHR usage.

Closes https://github.com/facebook/react-native/issues/872
Closes https://github.com/facebook/react-native/pull/892
Github Author: Josh Zana <joshzana@gmail.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-04-21 16:45:32 -08:00
Mike Wilcox 17e5b04d1a Fix Typo
Summary:
* This PR fixes a typo for the NetInfo docs page
Closes https://github.com/facebook/react-native/pull/937
Github Author: Mike Wilcox <mwilcox56@gmail.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-04-21 16:41:34 -08:00
Nick Lockwood bbd5259586 Fixed reachability 2015-04-20 08:33:56 -08:00
Mike Driver b1850f8fca Implemented response headers when using `XMLHttpRequest`
Summary:
I think perhaps these were left out by mistake?
Closes https://github.com/facebook/react-native/pull/382
Github Author: Mike Driver <mikedriver@gmail.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-04-09 19:31:57 -08:00
Alex Akers 8a57c4e980 [React Native] RCT_EXPORT lvl.2 2015-04-08 08:34:10 -08:00
Nick Lockwood bf4868edda Added non-class-scanning-based approach fror registering js methods 2015-04-08 05:45:20 -08:00
laiso e35521300a (Xcode) Set indent=2 in all xcodeproj files.
Summary:
These are default settings now.
I saw my Xcode be configured indent=4.

![2015-03-30 12 16 11 pm](https://cloud.githubusercontent.com/assets/39830/6889697/98f8b930-d6d6-11e4-81c8-d2146855d127.png)

Closes https://github.com/facebook/react-native/pull/472
Github Author: laiso <laiso@lai.so>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-04-01 17:14:45 -08:00
Tadeu Zagallo 20291a02df [ReactNative] s/ReactKit/React/g 2015-03-26 02:42:24 -08:00
Tadeu Zagallo bbb78df076 [React Native] Add CocoaPods spec 2015-03-25 21:53:26 -08:00
Eric Vicenti cd81fee57c [ReactNative] Flow and doc formatting for NetInfo 2015-03-25 14:41:00 -08:00
Olivia Bishop 40d71e6c5b JS files from D1936817: Add to XMLHttpRequest android and share code with ios 2015-03-24 14:25:20 -08:00
Christopher Chedeau 1aeb02ada3 [ReactNative] Expanded license on obj-c files 2015-03-23 13:18:29 -08:00
Christopher Chedeau e1ef0328d9 [ReactNative] Expanded license on js files 2015-03-23 13:17:54 -08:00
Alex Akers 48cc440bd3 [React Native] Fix iOS 7 crashes b/c missing Photos.fmwk 2015-03-23 08:06:58 -08:00
Tadeu Zagallo 1289536fe1 [ReactNative] Return the appropriate status code from XHR 2015-03-19 09:27:06 -08:00
Spencer Ahrens 9086365faf [ReactNative] Strip prefixes from NativeModules keys 2015-03-17 21:54:27 -08:00
Spencer Ahrens d8ee4e87a1 [ReactKit] Remove NativeModulesDeprecated 2015-03-17 02:48:58 -08:00
Spencer Ahrens b396de3cc8 [ReactNative] s/RK/RCT in OSS 2015-03-17 02:48:57 -08:00
Eric Vicenti 310aef9dcc [ReactNative] NetworkInformation.reachability API w/ example 2015-03-16 13:44:40 -08:00
Nick Lockwood 2424711a03 Unforked ExceptionsManager, AlertManager and AppState 2015-03-11 13:46:35 -08:00
Nick Lockwood fb2f063ef5 Ported TabBarIOS to OSS and unified implementation 2015-03-05 17:16:19 -08:00
Spencer Ahrens 3daaf1741c [ReactNative] Clean up libraries and include paths 2015-03-03 10:46:34 -08:00
Nick Lockwood 3b11b9d6c3 [WIP] Migrated View Managers over to new architecture 2015-03-01 16:34:14 -08:00
Spencer Ahrens c7b5a1ddfa [ReactNative] Use local CocoaPod config for ReactNative modules 2015-02-27 08:36:53 -08:00
Spencer Ahrens 99f7a0ab9d [ReactNative] Pull out some OSS modules into separate libs 2015-02-27 08:36:52 -08:00