Skip to content

Commit 24dc8ea

Browse files
committed
Fix net task cancel issue.
1 parent 7fd5066 commit 24dc8ea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

STNetTaskQueue/STHTTPNetTaskQueueHandler.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)data
179179

180180
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
181181
{
182-
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)task.response;
183-
if (!httpResponse) { // NSURLSessionTask is cancelled
182+
if (error && error.code == NSURLErrorCancelled) {
184183
return;
185184
}
186185

186+
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)task.response;
187187
NSData *data = [NSData dataWithData:_data];
188188
if (httpResponse.statusCode >= 200 && httpResponse.statusCode < 300) {
189189
id responseObj = nil;

0 commit comments

Comments
 (0)