diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 292253e0..e4e357e1 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -352,7 +352,19 @@ request.networkServiceType = NSURLNetworkServiceTypeBackground; } - [request setValue:[updater userAgentString] forHTTPHeaderField:@"User-Agent"]; + NSString *userAgentString = [updater userAgentString]; + if (userAgentString) { + [request setValue:userAgentString forHTTPHeaderField:@"User-Agent"]; + } + + NSDictionary *httpHeaders = [updater httpHeaders]; + if (httpHeaders) { + for (NSString *key in httpHeaders) { + NSString *value = [httpHeaders objectForKey:key]; + [request setValue:value forHTTPHeaderField:key]; + } + } + if ([[updater delegate] respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) { [[updater delegate] updater:self.updater willDownloadUpdate:self.updateItem diff --git a/Sparkle/SUUpdater.h b/Sparkle/SUUpdater.h index 54ce0902..45cd984d 100644 --- a/Sparkle/SUUpdater.h +++ b/Sparkle/SUUpdater.h @@ -149,14 +149,14 @@ SU_EXPORT @interface SUUpdater : NSObject @property (strong, readonly) NSBundle *sparkleBundle; /*! - The user agent used when checking for updates. + The user agent used when checking for and downloading updates. The default implementation can be overrided. */ @property (nonatomic, copy) NSString *userAgentString; /*! - The HTTP headers used when checking for updates. + The HTTP headers used when checking for and downloading updates. The keys of this dictionary are HTTP header fields (NSString) and values are corresponding values (NSString) */