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:
Nick Lockwood
2015-10-13 08:12:54 -07:00
committed by facebook-github-bot-4
parent 28f6eba22d
commit a92f107712
7 changed files with 135 additions and 40 deletions

View File

@@ -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];
}