Skip to content

Commit 36bcd7c

Browse files
author
garenwang
committed
兼容countOfBytesExpectedToSend 异常问题
1 parent 4ff4736 commit 36bcd7c

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

QCloudCore/Classes/Base/CustomLoader/QCloudCustomLoaderTask.h

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
1414
@property (nullable, readwrite, copy) NSHTTPURLResponse *response;
1515
@property (nullable, readwrite, copy) NSURLRequest *currentRequest;
1616
@property (nullable, readwrite, copy) NSURLRequest *originalRequest;
17+
@property (atomic, assign) int64_t countOfBytesSent;
18+
@property (atomic, assign) int64_t countOfBytesExpectedToSend;
1719

1820
/// 子类实现,用于构建自定义task。
1921
/// - Parameters:

QCloudCore/Classes/Base/CustomLoader/QCloudCustomLoaderTask.m

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ @implementation QCloudCustomLoaderTask
1818
@synthesize response = _response;
1919
@synthesize originalRequest = _originalRequest;
2020
@synthesize currentRequest = _currentRequest;
21+
@synthesize countOfBytesSent = _countOfBytesSent;
22+
@synthesize countOfBytesExpectedToSend = _countOfBytesExpectedToSend;
2123

2224

2325
- (instancetype)initWithHTTPRequest:(NSMutableURLRequest *)httpRequest

QCloudCore/Classes/Base/QCLOUDRestNet/SessionSupport/QCloudHTTPSessionManager.m

+5-1
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,13 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didComp
367367
if ([task respondsToSelector:@selector(countOfBytesSent)]) {
368368
countOfBytesSent = task.countOfBytesSent;
369369
}
370+
int64_t countOfBytesExpectedToSend = 0;
371+
if ([task respondsToSelector:@selector(countOfBytesExpectedToSend)]) {
372+
countOfBytesExpectedToSend = task.countOfBytesExpectedToSend;
373+
}
370374
[taskData.httpRequest notifySendProgressBytesSend:-(countOfBytesSent)
371375
totalBytesSend:countOfBytesSent
372-
totalBytesExpectedToSend:task.countOfBytesExpectedToSend];
376+
totalBytesExpectedToSend:countOfBytesExpectedToSend];
373377
}
374378
QCloudHTTPRequest *httpRequset = taskData.httpRequest;
375379
[taskData restData];

0 commit comments

Comments
 (0)