SDWebImageDownloaderResponseModifier

@protocol SDWebImageDownloaderResponseModifier <NSObject>

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.

  • Modify the original URL response and return a new response. You can use this to check MIME-Type, mock server response, etc.

    Note

    If nil is returned, the image download will marked as cancelled with error SDWebImageErrorInvalidDownloadResponse

    Declaration

    Objective-C

    - (nullable NSURLResponse *)modifiedResponseWithResponse:
        (nonnull NSURLResponse *)response;

    Swift

    func modifiedResponse(with response: URLResponse) -> URLResponse?

    Parameters

    response

    The original URL response, note for HTTP request it’s actually a NSHTTPURLResponse instance