Repository: SDWebImage/SDWebImage
File: SDWebImage/SDWebImageManager.m (Objective-C)

Code before:
    });
}

- (SDWebImageContext *)processedContextWithContext:(SDWebImageContext *)context {
    SDWebImageMutableContext *mutableContext = [SDWebImageMutableContext dictionary];
    
    // Image Transformer from manager
    if (!context[SDWebImageContextImageTransformer]) {
        id<SDImageTransformer> transformer = self.transformer;
        [mutableContext setValue:transformer forKey:SDWebImageContextImageTransformer];
    }
    // Cache key filter from manager
    if (!context[SDWebImageContextCacheKeyFilter]) {
        id<SDWebImageCacheKeyFilter> cacheKeyFilter = self.cacheKeyFilter;
        [mutableContext setValue:cacheKeyFilter forKey:SDWebImageContextCacheKeyFilter];
    }
    // Cache serializer from manager
    if (!context[SDWebImageContextCacheSerializer]) {
        id<SDWebImageCacheSerializer> cacheSerializer = self.cacheSerializer;
        [mutableContext setValue:cacheSerializer forKey:SDWebImageContextCacheSerializer];
    }
    
    if (mutableContext.count == 0) {
        return context;
    } else {
        [mutableContext addEntriesFromDictionary:context];
        return [mutableContext copy];
    }
}

@end


@implementation SDWebImageCombinedOperation

- (void)cancel {
    @synchronized(self) {
        if (self.isCancelled) {
            return;
        }
        self.cancelled = YES;
        if (self.cacheOperation) {
            [self.cacheOperation cancel];
            self.cacheOperation = nil;
        }
        if (self.loaderOperation) {
            [self.loaderOperation cancel];
            self.loaderOperation = nil;
        }
        [self.manager safelyRemoveOperationFromRunning:self];
    }

Review comment (refactor):
Attention! please don't do this things in a refactor `PR`. This break the processing logical. I'll revert this.

Code after:
            completionBlock(image, data, error, cacheType, finished, url);
        }
    });
}

- (BOOL)shouldBlockFailedURLWithURL:(nonnull NSURL *)url
                              error:(nonnull NSError *)error {
    // Check whether we should block failed url
    BOOL shouldBlockFailedURL;
    if ([self.delegate respondsToSelector:@selector(imageManager:shouldBlockFailedURL:withError:)]) {
        shouldBlockFailedURL = [self.delegate imageManager:self shouldBlockFailedURL:url withError:error];
    } else {
        NSString *domain = error.domain;
        NSInteger code = error.code;
        if ([domain isEqualToString:NSURLErrorDomain]) {
            shouldBlockFailedURL = (   code != NSURLErrorNotConnectedToInternet
                                    && code != NSURLErrorCancelled
                                    && code != NSURLErrorTimedOut
                                    && code != NSURLErrorInternationalRoamingOff
                                    && code != NSURLErrorDataNotAllowed
                                    && code != NSURLErrorCannotFindHost
                                    && code != NSURLErrorCannotConnectToHost
                                    && code != NSURLErrorNetworkConnectionLost);
        } else {
            // Custom loader, don't do extra error code check
            shouldBlockFailedURL = NO;
        }
    }
    
    return shouldBlockFailedURL;
}

- (SDWebImageContext *)processedContextWithContext:(SDWebImageContext *)context {
    SDWebImageMutableContext *mutableContext = [SDWebImageMutableContext dictionary];
    
    // Image Transformer from manager
    if (!context[SDWebImageContextImageTransformer]) {
        id<SDImageTransformer> transformer = self.transformer;
        [mutableContext setValue:transformer forKey:SDWebImageContextImageTransformer];
    }
    // Cache key filter from manager
    if (!context[SDWebImageContextCacheKeyFilter]) {
        id<SDWebImageCacheKeyFilter> cacheKeyFilter = self.cacheKeyFilter;
        [mutableContext setValue:cacheKeyFilter forKey:SDWebImageContextCacheKeyFilter];
    }
    // Cache serializer from manager
    if (!context[SDWebImageContextCacheSerializer]) {
        id<SDWebImageCacheSerializer> cacheSerializer = self.cacheSerializer;
        [mutableContext setValue:cacheSerializer forKey:SDWebImageContextCacheSerializer];
    }