diff --git a/SDWebImage/Core/SDWebImageDownloaderRequestModifier.h b/SDWebImage/Core/SDWebImageDownloaderRequestModifier.h index ed07b2dc..eabdf61d 100644 --- a/SDWebImage/Core/SDWebImageDownloaderRequestModifier.h +++ b/SDWebImage/Core/SDWebImageDownloaderRequestModifier.h @@ -17,6 +17,9 @@ typedef NSURLRequest * _Nullable (^SDWebImageDownloaderRequestModifierBlock)(NSU */ @protocol SDWebImageDownloaderRequestModifier +/// Modify the original URL request and return a new one instead. You can modify the HTTP header, cachePolicy, etc for this URL. +/// @param request The original URL request for image loading +/// @note If return nil, the URL request will be cancelled. - (nullable NSURLRequest *)modifiedRequestWithRequest:(nonnull NSURLRequest *)request; @end diff --git a/SDWebImage/Core/SDWebImageDownloaderResponseModifier.h b/SDWebImage/Core/SDWebImageDownloaderResponseModifier.h index ed5823cb..59cee9e8 100644 --- a/SDWebImage/Core/SDWebImageDownloaderResponseModifier.h +++ b/SDWebImage/Core/SDWebImageDownloaderResponseModifier.h @@ -18,7 +18,15 @@ typedef NSData * _Nullable (^SDWebImageDownloaderResponseModifierDataBlock)(NSDa */ @protocol SDWebImageDownloaderResponseModifier +/// Modify the original download data and return a new data. You can use this to decrypt the data using your perfereed algorithm. +/// @param data The original download data +/// @param response The URL response for data. If you modifiy the original URL response via the method below, the modified version will be here . This arg is nullable. +/// @note If nil is returned, the image download will marked as failed with error `SDWebImageErrorBadImageData` - (nullable NSData *)modifiedDataWithData:(nonnull NSData *)data response:(nullable NSURLResponse *)response; + +/// 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 @@ -37,7 +45,7 @@ typedef NSData * _Nullable (^SDWebImageDownloaderResponseModifierDataBlock)(NSDa /// Convenience way to create response modifier for common data encryption. @interface SDWebImageDownloaderResponseModifier (Conveniences) -/// Base64 Encoded image data +/// Base64 Encoded image data decrypter @property (class, readonly, nonnull) SDWebImageDownloaderResponseModifier *base64ResponseModifier; @end