mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 09:35:48 +00:00
f88bc3eb73
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/
37 lines
1.1 KiB
Objective-C
37 lines
1.1 KiB
Objective-C
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
/**
|
|
* An abstract interface used by request handler modules to send
|
|
* data back over the bridge back to JS.
|
|
*/
|
|
@protocol RCTURLRequestDelegate <NSObject>
|
|
|
|
/**
|
|
* Call this when you first receives a response from the server. This should
|
|
* include response headers, etc.
|
|
*/
|
|
- (void)URLRequest:(id)requestToken didReceiveResponse:(NSURLResponse *)response;
|
|
|
|
/**
|
|
* Call this when you receive data from the server. This can be called multiple
|
|
* times with partial data chunks, or just once with the full data packet.
|
|
*/
|
|
- (void)URLRequest:(id)requestToken didReceiveData:(NSData *)data;
|
|
|
|
/**
|
|
* Call this when the request is complete and/or if an error is encountered.
|
|
* For a successful request, the error parameter should be nil.
|
|
*/
|
|
- (void)URLRequest:(id)requestToken didCompleteWithError:(NSError *)error;
|
|
|
|
@end
|