Kingfisher Documentation

Protocol Image​Download​Request​Modifier

public protocol ImageDownloadRequestModifier: AsyncImageDownloadRequestModifier  

Represents and wraps a method for modifying request before an image download request starts.

%139 ImageDownloadRequestModifier ImageDownloadRequestModifier AsyncImageDownloadRequestModifier AsyncImageDownloadRequestModifier ImageDownloadRequestModifier->AsyncImageDownloadRequestModifier AnyModifier AnyModifier AnyModifier->ImageDownloadRequestModifier

Conforms To

AsyncImageDownloadRequestModifier

Represents and wraps a method for modifying request before an image download request starts in an asynchronous way.

Types Conforming to Image​Download​Request​Modifier

AnyModifier

A wrapper for creating an ImageDownloadRequestModifier easier. This type conforms to ImageDownloadRequestModifier and wraps an image modify block.

Default Implementations

modified(for:​report​Modified:​)

public func modified(for request: URLRequest, reportModified: @escaping (URLRequest?) -> Void)  

on​Download​Task​Started

public var onDownloadTaskStarted: ((DownloadTask?) -> Void)?  

This is nil for a sync ImageDownloadRequestModifier by default. You can get the DownloadTask from the return value of downloader method.

Requirements

modified(for:​)

func modified(for request: URLRequest) -> URLRequest? 

This method will be called just before the request being sent. This is the last chance you can modify the image download request. You can modify the request for some customizing purpose, such as adding auth token to the header, do basic HTTP auth or something like url mapping.

Usually, you pass an ImageDownloadRequestModifier as the associated value of KingfisherOptionsInfoItem.requestModifier and use it as the options parameter in related methods.

If you do nothing with the input request and return it as is, a downloading process will start with it.

Parameters

request URLRequest

The input request contains necessary information like url. This request is generated according to your resource url as a GET request.

Returns

A modified version of request, which you wish to use for downloading an image. If nil returned, a KingfisherError.requestError with .emptyRequest as its reason will occur.