/* * This file is part of the SDWebImage package. * (c) Olivier Poitrey * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ #import #import "SDWebImageCompat.h" typedef NSURLResponse * _Nullable (^SDWebImageDownloaderResponseModifierBlock)(NSURLResponse * _Nonnull response); /** This is the protocol for downloader response modifier. We can use a block to specify the downloader response modifier. But Using protocol can make this extensible, and allow Swift user to use it easily instead of using `@convention(block)` to store a block into context options. */ @protocol SDWebImageDownloaderResponseModifier /// Modify the original URL response and return a new response. You can use this to check MIME-Type, mock server response, etc. /// @param response The original URL response, note for HTTP request it's actually a `NSHTTPURLResponse` instance /// @note If nil is returned, the image download will marked as cancelled with error `SDWebImageErrorInvalidDownloadResponse` - (nullable NSURLResponse *)modifiedResponseWithResponse:(nonnull NSURLResponse *)response; @end /** A downloader response modifier class with block. */ @interface SDWebImageDownloaderResponseModifier : NSObject - (nonnull instancetype)initWithBlock:(nonnull SDWebImageDownloaderResponseModifierBlock)block; + (nonnull instancetype)responseModifierWithBlock:(nonnull SDWebImageDownloaderResponseModifierBlock)block; @end