...
|
...
|
@@ -13,6 +13,7 @@ |
|
|
|
|
|
@property (strong, nonatomic) AFHTTPRequestOperationManager *httpClient;
|
|
|
@property (readwrite, nonatomic, copy) YHNetworkReachabilityStatusBlock networkReachabilityStatusBlock;
|
|
|
@property (strong, nonatomic) AFHTTPRequestOperationManager *baiduManager;
|
|
|
|
|
|
@end
|
|
|
|
...
|
...
|
@@ -37,6 +38,15 @@ |
|
|
self.httpClient.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
|
|
|
self.httpClient.securityPolicy.allowInvalidCertificates = YES;
|
|
|
self.httpClient.operationQueue.maxConcurrentOperationCount = 6;
|
|
|
|
|
|
self.baiduManager = [AFHTTPRequestOperationManager manager];
|
|
|
[self.baiduManager.requestSerializer willChangeValueForKey:@"timeoutInterval"];
|
|
|
self.baiduManager.requestSerializer.timeoutInterval = 10.f;
|
|
|
[self.baiduManager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
|
|
|
AFHTTPResponseSerializer *responseSerializer = [AFHTTPResponseSerializer serializer];
|
|
|
responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/json", @"text/plain", @"text/html", @"text/xml", nil];
|
|
|
[self.baiduManager setResponseSerializer:responseSerializer];
|
|
|
|
|
|
}
|
|
|
return self;
|
|
|
}
|
...
|
...
|
@@ -195,4 +205,25 @@ |
|
|
}
|
|
|
}
|
|
|
|
|
|
#pragma mark baidu
|
|
|
- (void)getbaiduNetStatus:(NSDictionary *)parameters completionBlock:(void (^)(NSTimeInterval cts, NSInteger errCode))block
|
|
|
{
|
|
|
NSDate *startDate = [NSDate date];
|
|
|
[self.baiduManager POST:kbaiduApiMethod parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
|
|
|
NSDate *endDate = [NSDate date];
|
|
|
if (block) {
|
|
|
NSTimeInterval cts = [endDate timeIntervalSinceDate:startDate] * 1000.0;
|
|
|
block(cts,operation.response.statusCode);
|
|
|
}
|
|
|
|
|
|
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
|
|
NSLog(@"%zd",operation.response.statusCode);
|
|
|
NSDate *endDate = [NSDate date];
|
|
|
if (block) {
|
|
|
NSTimeInterval cts = [endDate timeIntervalSinceDate:startDate] * 1000.0;
|
|
|
block(cts,error.code);
|
|
|
}
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
@end |
...
|
...
|
|