Merge pull request #381 from josephroque/timeout-ios

Respect readTimeout for downloadFile on iOS
This commit is contained in:
Hagen Hübel 2017-11-17 00:05:34 +01:00 committed by GitHub
commit f037c79ec9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 1 deletions

View File

@ -17,6 +17,7 @@ typedef void (^ProgressCallback)(NSNumber*, NSNumber*);
@property bool background; // Whether to continue download when app is in background
@property bool discretionary; // Whether the file may be downloaded at the OS's discretion (iOS only)
@property (copy) NSNumber* progressDivider;
@property (copy) NSNumber* readTimeout;
@end

View File

@ -51,6 +51,7 @@
}
config.HTTPAdditionalHeaders = _params.headers;
config.timeoutIntervalForRequest = [_params.readTimeout intValue] / 1000.0;
_session = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:nil];
_task = [_session downloadTaskWithURL:url];

View File

@ -508,7 +508,7 @@ type DownloadFileOptions = {
begin?: (res: DownloadBeginCallbackResult) => void;
progress?: (res: DownloadProgressCallbackResult) => void;
connectionTimeout?: number // only supported on Android yet
readTimeout?: number // only supported on Android yet
readTimeout?: number // supported on Android and iOS
};
```
```

View File

@ -431,6 +431,8 @@ RCT_EXPORT_METHOD(downloadFile:(NSDictionary *)options
params.discretionary = [discretionary boolValue];
NSNumber* progressDivider = options[@"progressDivider"];
params.progressDivider = progressDivider;
NSNumber* readTimeout = options[@"readTimeout"];
params.readTimeout = readTimeout;
__block BOOL callbackFired = NO;