[Objc] Moved [request setHTTPShouldHandleCookies:NO]; to postProcessRequest method for easier override to modify request.

This commit is contained in:
Mateusz Mackowiak 2016-05-11 18:20:15 +02:00
parent 567c23a3df
commit ac37c43649
3 changed files with 17 additions and 15 deletions

View File

@ -329,10 +329,7 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
} }
// request cache // request cache
BOOL hasHeaderParams = false; BOOL hasHeaderParams = [headerParams count] > 0;
if (headerParams != nil && [headerParams count] > 0) {
hasHeaderParams = true;
}
if (offlineState) { if (offlineState) {
{{classPrefix}}DebugLog(@"%@ cache forced", resourcePath); {{classPrefix}}DebugLog(@"%@ cache forced", resourcePath);
[request setCachePolicy:NSURLRequestReturnCacheDataDontLoad]; [request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
@ -353,9 +350,7 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
} }
[self.requestSerializer setValue:responseContentType forHTTPHeaderField:@"Accept"]; [self.requestSerializer setValue:responseContentType forHTTPHeaderField:@"Accept"];
[self postProcessRequest:request];
// Always disable cookies!
[request setHTTPShouldHandleCookies:NO];
NSNumber* requestId = [{{classPrefix}}ApiClient queueRequest]; NSNumber* requestId = [{{classPrefix}}ApiClient queueRequest];
if ([responseType isEqualToString:@"NSURL*"] || [responseType isEqualToString:@"NSURL"]) { if ([responseType isEqualToString:@"NSURL*"] || [responseType isEqualToString:@"NSURL"]) {
@ -376,6 +371,12 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
return requestId; return requestId;
} }
//Added for easier override to modify request
-(void)postProcessRequest:(NSMutableURLRequest *)request {
// Always disable cookies!
[request setHTTPShouldHandleCookies:NO];
}
#pragma mark - #pragma mark -
- (NSString*) pathWithQueryParamsToString:(NSString*) path - (NSString*) pathWithQueryParamsToString:(NSString*) path

View File

@ -6,7 +6,7 @@ This ObjC package is automatically generated by the [Swagger Codegen](https://gi
- API version: 1.0.0 - API version: 1.0.0
- Package version: - Package version:
- Build date: 2016-05-11T17:37:37.440+02:00 - Build date: 2016-05-11T18:16:45.229+02:00
- Build package: class io.swagger.codegen.languages.ObjcClientCodegen - Build package: class io.swagger.codegen.languages.ObjcClientCodegen
## Requirements ## Requirements

View File

@ -329,10 +329,7 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
} }
// request cache // request cache
BOOL hasHeaderParams = false; BOOL hasHeaderParams = [headerParams count] > 0;
if (headerParams != nil && [headerParams count] > 0) {
hasHeaderParams = true;
}
if (offlineState) { if (offlineState) {
SWGDebugLog(@"%@ cache forced", resourcePath); SWGDebugLog(@"%@ cache forced", resourcePath);
[request setCachePolicy:NSURLRequestReturnCacheDataDontLoad]; [request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
@ -353,9 +350,7 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
} }
[self.requestSerializer setValue:responseContentType forHTTPHeaderField:@"Accept"]; [self.requestSerializer setValue:responseContentType forHTTPHeaderField:@"Accept"];
[self postProcessRequest:request];
// Always disable cookies!
[request setHTTPShouldHandleCookies:NO];
NSNumber* requestId = [SWGApiClient queueRequest]; NSNumber* requestId = [SWGApiClient queueRequest];
if ([responseType isEqualToString:@"NSURL*"] || [responseType isEqualToString:@"NSURL"]) { if ([responseType isEqualToString:@"NSURL*"] || [responseType isEqualToString:@"NSURL"]) {
@ -376,6 +371,12 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
return requestId; return requestId;
} }
//Added for easier override to modify request
-(void)postProcessRequest:(NSMutableURLRequest *)request {
// Always disable cookies!
[request setHTTPShouldHandleCookies:NO];
}
#pragma mark - #pragma mark -
- (NSString*) pathWithQueryParamsToString:(NSString*) path - (NSString*) pathWithQueryParamsToString:(NSString*) path