From 4eaedee9ab11bd505147449fc2deeda01fee3869 Mon Sep 17 00:00:00 2001 From: Zorg Date: Fri, 6 Dec 2024 22:48:22 -0800 Subject: [PATCH] Add custom timeout setting for testing unreliable connection --- Sparkle/SPUDownloadDriver.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Sparkle/SPUDownloadDriver.m b/Sparkle/SPUDownloadDriver.m index 61b551d9ec..6408cfe166 100644 --- a/Sparkle/SPUDownloadDriver.m +++ b/Sparkle/SPUDownloadDriver.m @@ -112,7 +112,18 @@ - (instancetype)initWithRequestURL:(NSURL *)requestURL host:(SUHost *)host userA _delegate = delegate; _inBackground = background; - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0]; + NSProcessInfo *processInfo = [NSProcessInfo processInfo]; + NSString *customTimeout = processInfo.environment[@"SPARKLE_TIMEOUT"]; + NSTimeInterval timeout; + if (customTimeout != nil) { + timeout = customTimeout.doubleValue; + } else { + timeout = 60.0; + } + + NSLog(@"SPARKLE_TIMEOUT: %f", timeout); + + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:timeout]; if (userAgent != nil) { [request setValue:(NSString * _Nonnull)userAgent forHTTPHeaderField:@"User-Agent"];