mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
Pass http headers and user agent when downloading release notes
This commit is contained in:
1 parent
c0933a516b
commit
99785ceebb
3 files changed
+25
-4
No files matched your search
Vendored
+1
-1
@@ -83,7 +83,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:updateItem host:self.host completionBlock:^(SUUpdateAlertChoice choice) {
|
||||
self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:updateItem httpHeaders:updater.httpHeaders userAgent:updater.userAgentString host:self.host completionBlock:^(SUUpdateAlertChoice choice) {
|
||||
[self updateAlertFinishedWithChoice:choice forItem:updateItem];
|
||||
}];
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -26,7 +26,7 @@ typedef NS_ENUM(NSInteger, SUUpdateAlertChoice) {
|
||||
|
||||
@property (weak) id<SUVersionDisplay> versionDisplayer;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host completionBlock:(void(^)(SUUpdateAlertChoice))c;
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item httpHeaders:(NSDictionary *)httpHeaders userAgent:(NSString *)userAgent host:(SUHost *)host completionBlock:(void(^)(SUUpdateAlertChoice))c;
|
||||
|
||||
- (IBAction)installUpdate:sender;
|
||||
- (IBAction)skipThisVersion:sender;
|
||||
|
||||
Vendored
+23
-2
@@ -49,6 +49,9 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
|
||||
@property (nonatomic) id<SUWebView> webView;
|
||||
|
||||
@property (nonatomic) NSDictionary *httpHeaders;
|
||||
@property (nonatomic) NSString *userAgent;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUUpdateAlert
|
||||
@@ -74,7 +77,10 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
|
||||
@synthesize webView = _webView;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost completionBlock:(void (^)(SUUpdateAlertChoice))block
|
||||
@synthesize httpHeaders = _httpHeaders;
|
||||
@synthesize userAgent = _userAgent;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item httpHeaders:(NSDictionary *)httpHeaders userAgent:(NSString *)userAgent host:(SUHost *)aHost completionBlock:(void (^)(SUUpdateAlertChoice))block
|
||||
{
|
||||
self = [super initWithWindowNibName:@"SUUpdateAlert"];
|
||||
if (self)
|
||||
@@ -82,6 +88,8 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
self.completionBlock = block;
|
||||
host = aHost;
|
||||
updateItem = item;
|
||||
_httpHeaders = httpHeaders;
|
||||
_userAgent = userAgent;
|
||||
[self setShouldCascadeWindows:NO];
|
||||
}
|
||||
return self;
|
||||
@@ -145,8 +153,21 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
// If there's a release notes URL, load it; otherwise, just stick the contents of the description into the web view.
|
||||
if ([self.updateItem releaseNotesURL])
|
||||
{
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem releaseNotesURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30];
|
||||
|
||||
if (self.userAgent) {
|
||||
[request setValue:self.userAgent forHTTPHeaderField:@"User-Agent"];
|
||||
}
|
||||
|
||||
if (self.httpHeaders) {
|
||||
for (NSString *key in self.httpHeaders) {
|
||||
NSString *value = [self.httpHeaders objectForKey:key];
|
||||
[request setValue:value forHTTPHeaderField:key];
|
||||
}
|
||||
}
|
||||
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
[self.webView loadRequest:[NSURLRequest requestWithURL:[self.updateItem releaseNotesURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30] completionHandler:^(NSError * _Nullable error) {
|
||||
[self.webView loadRequest:request completionHandler:^(NSError * _Nullable error) {
|
||||
if (error != nil) {
|
||||
SULog(SULogLevelError, @"Failed to load URL request from web view: %@", error);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user