mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
Apply custom headers to app download
The custom headers added in #489 only applied to the appcast download. This makes them apply to the app download as well for the case when both are hosted behind authentication.
This commit is contained in:
1 parent
2b9a02c825
commit
3f226ccdd7
4 files changed
+15
-5
No files matched your search
Vendored
+4
-1
@@ -41,6 +41,7 @@
|
||||
@property (nonatomic, readonly, weak) id updater; // if we didn't have legacy support, I'd remove this..
|
||||
@property (nullable, nonatomic, readonly, weak) id <SPUUpdaterDelegate>updaterDelegate;
|
||||
@property (nonatomic) NSString *userAgent;
|
||||
@property (nonatomic, nullable) NSDictionary *httpHeaders;
|
||||
|
||||
@end
|
||||
|
||||
@@ -58,6 +59,7 @@
|
||||
@synthesize updater = _updater;
|
||||
@synthesize updaterDelegate = _updaterDelegate;
|
||||
@synthesize userAgent = _userAgent;
|
||||
@synthesize httpHeaders = _httpHeaders;
|
||||
@synthesize resumableUpdate = _resumableUpdate;
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate delegate:(id<SPUCoreBasedUpdateDriverDelegate>)delegate
|
||||
@@ -111,6 +113,7 @@
|
||||
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background includesSkippedUpdates:(BOOL)includesSkippedUpdates requiresSilentInstall:(BOOL)silentInstall
|
||||
{
|
||||
self.userAgent = userAgent;
|
||||
self.httpHeaders = httpHeaders;
|
||||
self.silentInstall = silentInstall;
|
||||
|
||||
[self.basicDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:background includesSkippedUpdates:includesSkippedUpdates];
|
||||
@@ -167,7 +170,7 @@
|
||||
|
||||
- (void)downloadUpdateFromAppcastItem:(SUAppcastItem *)updateItem inBackground:(BOOL)background
|
||||
{
|
||||
self.downloadDriver = [[SPUDownloadDriver alloc] initWithUpdateItem:updateItem host:self.host userAgent:self.userAgent inBackground:background delegate:self];
|
||||
self.downloadDriver = [[SPUDownloadDriver alloc] initWithUpdateItem:updateItem host:self.host userAgent:self.userAgent httpHeaders:self.httpHeaders inBackground:background delegate:self];
|
||||
|
||||
if ([self.updaterDelegate respondsToSelector:@selector((updater:willDownloadUpdate:withRequest:))]) {
|
||||
[self.updaterDelegate updater:self.updater
|
||||
|
||||
Vendored
+1
-1
@@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SPUDownloadDriver : NSObject
|
||||
|
||||
- (instancetype)initWithUpdateItem:(SUAppcastItem *)updateItem host:(SUHost *)host userAgent:(NSString *)userAgent inBackground:(BOOL)background delegate:(id<SPUDownloadDriverDelegate>)delegate;
|
||||
- (instancetype)initWithUpdateItem:(SUAppcastItem *)updateItem host:(SUHost *)host userAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background delegate:(id<SPUDownloadDriverDelegate>)delegate;
|
||||
|
||||
- (void)downloadUpdate;
|
||||
|
||||
|
||||
Vendored
+8
-1
@@ -53,7 +53,7 @@
|
||||
@synthesize expectedContentLength = _expectedContentLength;
|
||||
@synthesize cleaningUp = _cleaningUp;
|
||||
|
||||
- (instancetype)initWithUpdateItem:(SUAppcastItem *)updateItem host:(SUHost *)host userAgent:(NSString *)userAgent inBackground:(BOOL)background delegate:(id<SPUDownloadDriverDelegate>)delegate
|
||||
- (instancetype)initWithUpdateItem:(SUAppcastItem *)updateItem host:(SUHost *)host userAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background delegate:(id<SPUDownloadDriverDelegate>)delegate
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
@@ -65,6 +65,13 @@
|
||||
_request = [NSMutableURLRequest requestWithURL:updateItem.fileURL];
|
||||
[_request setValue:userAgent forHTTPHeaderField:@"User-Agent"];
|
||||
_request.networkServiceType = background ? NSURLNetworkServiceTypeBackground : NSURLNetworkServiceTypeDefault;
|
||||
|
||||
if (httpHeaders) {
|
||||
for (NSString *key in httpHeaders) {
|
||||
NSString *value = [httpHeaders objectForKey:key];
|
||||
[_request setValue:value forHTTPHeaderField:key];
|
||||
}
|
||||
}
|
||||
|
||||
if (!SPUXPCServiceExists(@DOWNLOADER_BUNDLE_ID)) {
|
||||
_downloader = [[SPUDownloader alloc] initWithDelegate:self];
|
||||
|
||||
Vendored
+2
-2
@@ -154,14 +154,14 @@ SU_EXPORT @interface SUUpdater : NSObject
|
||||
@property (nonatomic, 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)
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user