Skip to content

Commit 55e4e3d

Browse files
committed
Setting the Accept header type in the Client
1 parent a7583c9 commit 55e4e3d

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

Sources/OAuth2Client/NXOAuth2Client.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ extern NSString * const NXOAuth2ClientConnectionContextTokenRefresh;
6767

6868
@property (nonatomic, copy) NSSet *desiredScope;
6969
@property (nonatomic, copy) NSString *userAgent;
70+
@property (nonatomic, copy) NSString *acceptType; // defaults to application/json
7071

7172
@property (nonatomic, strong) NXOAuth2AccessToken *accessToken;
7273
@property (nonatomic, unsafe_unretained) NSObject<NXOAuth2ClientDelegate>* delegate;

Sources/OAuth2Client/NXOAuth2Client.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ - (id)initWithClientID:(NSString *)aClientId
9191
tokenType = [aTokenType copy];
9292
accessToken = anAccessToken;
9393

94+
self.acceptType = @"application/json";
95+
9496
self.persistent = shouldPersist;
9597
self.delegate = aDelegate;
9698
}

Sources/OAuth2Client/NXOAuth2Connection.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ - (NSURLConnection *)createConnection;
197197
[startRequest setValue:client.userAgent forHTTPHeaderField:@"User-Agent"];
198198
}
199199

200-
[startRequest setValue:@"application/json" forHTTPHeaderField:@"Accept"];
200+
if (client.acceptType) {
201+
[startRequest setValue:client.acceptType forHTTPHeaderField:@"Accept"];
202+
}
201203

202204
NSURLConnection *aConnection = [[NSURLConnection alloc] initWithRequest:startRequest delegate:self startImmediately:NO]; // don't start yet
203205
[aConnection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; // let's first schedule it in the current runloop. (see http://github.com/soundcloud/cocoa-api-wrapper/issues#issue/2 )

0 commit comments

Comments
 (0)