Authored by 孙凯

add 采用originalRequest review by hongmo

... ... @@ -25,31 +25,31 @@
#pragma mark - 属性
+(void)startTrack{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
@try {
SEL selectors[] = {
//@selector(dataTaskWithRequest:completionHandler:),
//@selector(downloadTaskWithRequest:completionHandler:),
};
for (NSUInteger index = 0; index < sizeof(selectors) / sizeof(SEL); ++index) {
SEL originalSelector = selectors[index];
SEL swizzledSelector = NSSelectorFromString([@"yher_" stringByAppendingString:NSStringFromSelector(originalSelector)]);
NSError *error = NULL;
[[self class] yh_swizzleMethod:originalSelector
withMethod:swizzledSelector
error:&error];
if (error) {
YHLog(@"Failed to swizzle: on UIControl. Details: %@", error);
error = NULL;
}
}
} @catch (NSException *exception) {
YHLog(@"%@ error: %@", self, exception);
}
});
// static dispatch_once_t onceToken;
// dispatch_once(&onceToken, ^{
// @try {
// SEL selectors[] = {
// //@selector(dataTaskWithRequest:completionHandler:),
// //@selector(downloadTaskWithRequest:completionHandler:),
// };
//
// for (NSUInteger index = 0; index < sizeof(selectors) / sizeof(SEL); ++index) {
// SEL originalSelector = selectors[index];
// SEL swizzledSelector = NSSelectorFromString([@"yher_" stringByAppendingString:NSStringFromSelector(originalSelector)]);
// NSError *error = NULL;
// [[self class] yh_swizzleMethod:originalSelector
// withMethod:swizzledSelector
// error:&error];
// if (error) {
// YHLog(@"Failed to swizzle: on UIControl. Details: %@", error);
// error = NULL;
// }
// }
//
// } @catch (NSException *exception) {
// YHLog(@"%@ error: %@", self, exception);
// }
// });
}
... ... @@ -162,9 +162,10 @@ static inline BOOL yher_addMethod(Class class, SEL selector, Method method) {
- (void)yher_resume
{
@try {
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isHttpPerformanceTrackEnable) {
NSURLSessionTask *task = (NSURLSessionTask*)self;
[[YH_EventCollector sharedInstance] timeEventStartWithRequestUrl:[task.currentRequest.URL absoluteString]];
NSString *hostInHTTPField = [task.originalRequest.allHTTPHeaderFields objectForKey:@"Host"];
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isHttpPerformanceTrackEnable && ([[task.originalRequest.URL host] isEqualToString:YHEventReportHttpHost] || [hostInHTTPField isEqualToString:YHEventReportHttpHost])) {
[[YH_EventCollector sharedInstance] timeEventStartWithRequestUrl:[task.originalRequest.URL absoluteString]];
}
} @catch (NSException *exception) {
YHLog(@"%@ error: %@", self, exception);
... ... @@ -173,3 +174,4 @@ static inline BOOL yher_addMethod(Class class, SEL selector, Method method) {
}
@end
... ...