mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-30 18:24:25 +08:00
Added RCTFileRequestHandler
Summary: @public We previously discovered that using an NSURLSessionDataTask to load local files is noticably less efficient than using regular filesystem methods. This diff adds RCTFileRequestHandler as a replacement for RCTHTTPRequestHandler when loading local files. This reduces loading time when loading local files via XMLHttpRequest, as well as improving the performance for some image load requests. Reviewed By: @javache Differential Revision: D2531710 fb-gh-sync-id: 259714baac131784de494d24939f42ad52bff41a
This commit is contained in:
committed by
facebook-github-bot-4
parent
28f6eba22d
commit
a92f107712
@@ -50,7 +50,9 @@ RCT_EXPORT_MODULE()
|
||||
static NSSet *schemes = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
schemes = [[NSSet alloc] initWithObjects:@"http", @"https", @"file", nil];
|
||||
// technically, RCTHTTPRequestHandler can handle file:// as well,
|
||||
// but it's less efficient than using RCTFileRequestHandler
|
||||
schemes = [[NSSet alloc] initWithObjects:@"http", @"https", nil];
|
||||
});
|
||||
return [schemes containsObject:request.URL.scheme.lowercaseString];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user