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

View File

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