Skip to content

Commit f216ef7

Browse files
committed
Merge pull request sparkle-project#489 from mgunneras/http-headers
Ability to add custom http headers to appcast request
2 parents 2a1760a + 1db20c4 commit f216ef7

5 files changed

Lines changed: 13 additions & 1 deletion

File tree

Sparkle/SUAppcast.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ SU_EXPORT @interface SUAppcast : NSObject <NSURLDownloadDelegate>
1919

2020
@property (weak) id<SUAppcastDelegate> delegate;
2121
@property (copy) NSString *userAgentString;
22+
@property (copy) NSDictionary *httpHeaders;
2223

2324
- (void)fetchAppcastFromURL:(NSURL *)url;
2425

Sparkle/SUAppcast.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ @implementation SUAppcast
4545
@synthesize downloadFilename;
4646
@synthesize delegate;
4747
@synthesize userAgentString;
48+
@synthesize httpHeaders;
4849
@synthesize download;
4950
@synthesize items;
5051

@@ -55,6 +56,13 @@ - (void)fetchAppcastFromURL:(NSURL *)url
5556
[request setValue:self.userAgentString forHTTPHeaderField:@"User-Agent"];
5657
}
5758

59+
if (self.httpHeaders) {
60+
for (NSString *key in self.httpHeaders) {
61+
id value = [self.httpHeaders objectForKey:key];
62+
[request setValue:value forHTTPHeaderField:key];
63+
}
64+
}
65+
5866
[request setValue:@"application/rss+xml,*/*;q=0.1" forHTTPHeaderField:@"Accept"];
5967

6068
self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self];

Sparkle/SUBasicUpdateDriver.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ - (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
5656

5757
[appcast setDelegate:self];
5858
[appcast setUserAgentString:[self.updater userAgentString]];
59+
[appcast setHttpHeaders:[self.updater httpHeaders]];
5960
[appcast fetchAppcastFromURL:URL];
6061
}
6162

Sparkle/SUUpdater.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ SU_EXPORT @interface SUUpdater : NSObject
4646

4747
@property (nonatomic, copy) NSString *userAgentString;
4848

49+
@property (copy) NSDictionary *httpHeaders;
50+
4951
@property BOOL sendsSystemProfile;
5052

5153
@property BOOL automaticallyDownloadsUpdates;

Sparkle/SUUpdater.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ @implementation SUUpdater
5151
@synthesize delegate;
5252
@synthesize checkTimer;
5353
@synthesize userAgentString = customUserAgentString;
54-
54+
@synthesize httpHeaders;
5555
@synthesize driver;
5656
@synthesize host;
5757

0 commit comments

Comments
 (0)