1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// PSDProxyEvent.h
// Poseidon
//
// Created by chenwenhong on 14-11-4.
// Copyright (c) 2014年 Alipay. All rights reserved.
//
#import "PSDEvent.h"
@class PSDResponse;
@interface PSDProxyEvent : PSDEvent
@property(nonatomic, readonly, copy) NSString *uniqueId;
@property(nonatomic, readonly, copy) NSString *channelId;
@property(nonatomic, strong) NSURLRequest *request; // 当前的请求对象
@property(nonatomic, strong) NSURLRequest *origRequest; // 当前请求为重定向时,指向上个请求
@property(nonatomic, readonly, strong) NSDate *requestDate; // 请求时间
@property(nonatomic, strong) NSURLResponse *response; // 响应对象
@property(nonatomic, readonly, strong) NSDate *responseDate; // 响应时间
@property(nonatomic, strong) NSData *receiveData; // 生效:kEvent_Proxy_Request_ReceiveData、kEvent_Proxy_Request_FinishReceiveData、kEvent_Proxy_Request_Finish;当event为kEvent_Proxy_Request_FinishReceiveData时,仅mimeType是:text/html、image/png、image/jpg、application/javascript、application/json、text/css时才有
@property(nonatomic, readonly, strong) NSError *error;
@property(nonatomic, assign) BOOL willRedirectRequest; // 生效:kEvent_Proxy_Request_Start_Handler、kEvent_Proxy_Request_Response_Handler
@property(nonatomic, assign) BOOL willHoldReceiveData; // 生效:kEvent_Proxy_Request_ReceiveData
@property(nonatomic, assign) NSUInteger receiveDataLength; // 生效:kEvent_Proxy_Request_Finish
@property(nonatomic, readonly, strong) PSDResponse *customResponse;
@property(nonatomic, strong) NSURLSessionTask *task;
@property(nonatomic, strong) NSURLSessionTaskMetrics *metrics;
//处理request
+ (instancetype)requestHandlerEvent:(NSURLRequest *)request
requestDate:(NSDate *)requestDate
customResponse:(PSDResponse *)customResponse
channelId:(NSString *)channelId;
+ (instancetype)startLoadEvent:(NSURLRequest *)request
requestDate:(NSDate *)requestDate
uniqueId:(NSString *)uniqueId
channelId:(NSString *)channelId;
//将要重定向
+ (instancetype)willRedirectEvent:(NSURLRequest *)request
origRequest:(NSURLRequest *)origRequest
redirectResponse:(NSURLResponse *)response
redirectDate:(NSDate *)redirectDate
uniqueId:(NSString *)uniqueId
channelId:(NSString *)channelId;
//处理response、重定向
+ (instancetype)responseHandler:(NSURLRequest *)request
response:(NSURLResponse *)response
requestDate:(NSDate *)requestDate
responseDate:(NSDate *)responseDate
channelId:(NSString *)channelId;
//处理response
+ (instancetype)receiveResponse:(NSURLResponse *)response
request:(NSURLRequest *)request
requestDate:(NSDate *)requestDate
responseDate:(NSDate *)responseDate
uniqueId:(NSString *)uniqueId
channelId:(NSString *)channelId;
//处理分段data
+ (instancetype)receiveDataEvent:(NSURLRequest *)request
response:(NSURLResponse *)response
receiveData:(NSData *)data
uniqueId:(NSString *)uniqueId
channelId:(NSString *)channelId;
//处理data
+ (instancetype)finishReceiveDataEvent:(NSURLRequest *)request
response:(NSURLResponse *)response
requestDate:(NSDate *)requestDate
responseDate:(NSDate *)responseDate
receiveData:(NSData *)data
error:(NSError *)error
uniqueId:(NSString *)uniqueId
channelId:(NSString *)channelId;
+ (instancetype)finishLoadEvent:(NSURLRequest *)request
response:(NSURLResponse *)response
requestDate:(NSDate *)requestDate
responseDate:(NSDate *)responseDate
receiveData:(NSData *)receiveData
receiveDataLength:(NSUInteger)receiveDataLength
error:(NSError *)error
uniqueId:(NSString *)uniqueId
channelId:(NSString *)channelId;
+ (instancetype)finishCollectingMetricsEvent:(NSURLSessionTaskMetrics *)metrics
request:(NSURLRequest *)request
response:(NSURLResponse *)response
task:(NSURLSessionTask *)task
uniqueId:(NSString *)uniqueId
channelId:(NSString *)channelId;
@end