File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed
Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,18 @@ - (void)initData{
3333 _countOfResponseBodyBytesReceived = 0 ;
3434}
3535
36+ - (void )setRequest : (NSURLRequest *)request {
37+ NSMutableURLRequest *newRequest = [NSMutableURLRequest requestWithURL: request.URL
38+ cachePolicy: request.cachePolicy
39+ timeoutInterval: request.timeoutInterval];
40+ newRequest.allHTTPHeaderFields = request.allHTTPHeaderFields ;
41+
42+ NSInteger headerLength = [NSString stringWithFormat: @" %@ " , self .request.allHTTPHeaderFields].length ;
43+ NSInteger bodyLength = [self .request.qn_getHttpBody length ];
44+ _totalBytes = @(headerLength + bodyLength);
45+ _request = [newRequest copy ];
46+ }
47+
3648- (NSNumber *)totalElapsedTime {
3749 return [self timeFromStartDate: self .startDate
3850 toEndDate: self .endDate];
@@ -68,12 +80,6 @@ - (NSNumber *)totalResponseTime{
6880 toEndDate: self .responseEndDate];
6981}
7082
71- - (NSNumber *)totalBytes {
72- NSInteger headerLength = [NSString stringWithFormat: @" %@ " , self .request.allHTTPHeaderFields].length ;
73- NSInteger bodyLength = [self .request.qn_getHttpBody length ];
74- return @(headerLength + bodyLength);
75- }
76-
7783- (NSNumber *)bytesSend {
7884 int64_t totalBytes = [self totalBytes ].integerValue ;
7985 int64_t senderBytes = self.countOfRequestBodyBytesSent + self.countOfRequestHeaderBytesSent ;
Original file line number Diff line number Diff line change @@ -62,12 +62,8 @@ - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)data
6262}
6363
6464- (void )URLSession : (NSURLSession *)session task : (NSURLSessionTask *)task didCompleteWithError : (nullable NSError *)error {
65- NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: task.currentRequest.URL
66- cachePolicy: task.currentRequest.cachePolicy
67- timeoutInterval: task.currentRequest.timeoutInterval];
68- request.allHTTPHeaderFields = task.currentRequest .allHTTPHeaderFields ;
6965 self.requestMetrics .endDate = [NSDate date ];
70- self.requestMetrics .request = [request copy ] ;
66+ self.requestMetrics .request = task. currentRequest ;
7167 self.requestMetrics .response = task.response ;
7268 self.requestMetrics .countOfResponseBodyBytesReceived = task.response .expectedContentLength ;
7369 self.requestMetrics .countOfRequestHeaderBytesSent = [NSString stringWithFormat: @" %@ " , task.currentRequest.allHTTPHeaderFields].length ;
You can’t perform that action at this time.
0 commit comments