Authored by 朱小军

session重置后,需要在请求的时候额外刷新header的session review by 尹诚

... ... @@ -42,9 +42,8 @@ static NSString *const YH_HTTP_PREFIX = @"http://";
self.httpClient.securityPolicy.allowInvalidCertificates = YES;
self.httpClient.operationQueue.maxConcurrentOperationCount = 6;
[self.httpClient.requestSerializer setValue:@"gzip" forHTTPHeaderField:@"Content-Encoding"];
if ([[YH_Analytics sharedInstance].session length] > 0) {
[self.httpClient.requestSerializer setValue:[[YH_Analytics sharedInstance] session] forHTTPHeaderField:@"x-yoho-sid"];
}
[self.httpClient.requestSerializer setValue:[[YH_Analytics sharedInstance] session] forHTTPHeaderField:@"x-yoho-sid"];
self.baiduManager = [AFHTTPRequestOperationManager manager];
AFHTTPResponseSerializer *responseSerializer = [AFHTTPResponseSerializer serializer];
responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/json", @"text/plain", @"text/html", @"text/xml", nil];
... ... @@ -62,6 +61,11 @@ static NSString *const YH_HTTP_PREFIX = @"http://";
self.httpClient = nil;
}
- (void)updateHttpClientRequestHTTPHeaderSid
{
[self.httpClient.requestSerializer setValue:[[YH_Analytics sharedInstance] session] forHTTPHeaderField:@"x-yoho-sid"];
}
- (NSString *)checkHttpsPrefix:(NSString *)urlString
{
urlString = [self urlStringByTransformToHttpsProtocol:urlString];//进行http->https的转换
... ... @@ -122,6 +126,8 @@ static NSString *const YH_HTTP_PREFIX = @"http://";
NSString *url = [self checkHttpsPrefix:kURLAnalyticsService];
[self updateHttpClientRequestHTTPHeaderSid];
return [self.httpClient POST:url priority:NSOperationQueuePriorityLow parameters:newParameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
if (block) {
... ... @@ -236,6 +242,8 @@ static NSString *const YH_HTTP_PREFIX = @"http://";
url = [self checkHttpsPrefix:url];
[self updateHttpClientRequestHTTPHeaderSid];
return [self.httpClient POST:url priority:NSOperationQueuePriorityLow parameters:newParameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
if (block) {
... ...