mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 21:46:07 +08:00
Added Gzip support
Summary: Added Gzip function to RCTUtils. This uses dlopen to load the zlib library at runtime so there's no need to link it into your project. The main reason for this feature is to support gzipping of HTTP request bodies. Now, if you add 'Content-Encoding:gzip' to your request headers when using XMLHttpRequest, your request body will be automatically gzipped on the native side before sending. (Note: Gzip decoding of *response* bodies is handled automatically by iOS, and was already available).
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTDefines.h"
|
||||
|
||||
// Utility functions for JSON object <-> string serialization/deserialization
|
||||
// JSON serialization/deserialization
|
||||
RCT_EXTERN NSString *RCTJSONStringify(id jsonObject, NSError **error);
|
||||
RCT_EXTERN id RCTJSONParse(NSString *jsonString, NSError **error);
|
||||
RCT_EXTERN id RCTJSONParseMutable(NSString *jsonString, NSError **error);
|
||||
@@ -24,7 +24,7 @@ RCT_EXTERN id RCTJSONParseWithOptions(NSString *jsonString, NSError **error, NSJ
|
||||
// Strip non JSON-safe values from an object graph
|
||||
RCT_EXTERN id RCTJSONClean(id object);
|
||||
|
||||
// Get MD5 hash of a string (TODO: currently unused. Remove?)
|
||||
// Get MD5 hash of a string
|
||||
RCT_EXTERN NSString *RCTMD5Hash(NSString *string);
|
||||
|
||||
// Get screen metrics in a thread-safe way
|
||||
@@ -64,3 +64,6 @@ RCT_EXTERN id RCTNullIfNil(id value);
|
||||
|
||||
// Convert data to a Base64-encoded data URL
|
||||
RCT_EXTERN NSURL *RCTDataURL(NSString *mimeType, NSData *data);
|
||||
|
||||
// Gzip functionality - compression level in range 0 - 1 (-1 for default)
|
||||
RCT_EXTERN NSData *RCTGzipData(NSData *data, float level);
|
||||
|
||||
Reference in New Issue
Block a user