Closed tgaul closed 8 months ago
When using a custom ImageDownloader
, you can use the init(session:downloadPrioritization:maximumActiveDownloads:imageCache:)
method to create a downloader with a completely custom Session
, which allows you to customize the base interceptor that is used for all requests.
Feature Request
When constructing a custom
ImageDownloader
, allow the client to pass in an optionalRequestInterceptor
that can be used to customize the headers of requests and retry behavior.Background
While updating our project from Alamofire 4 to Alamofire 5 and the corresponding version of AlamofireImage, one bit of customization we had added to the
ImageDownloader
no longer seems to be possible (unless I'm missing something).Specifically, we had the following code in our app initialization:
This was done so that if the response indicated a 503 server error, we would do an exponential backoff and retry the image request.
API Limitation
In Alamofire 5, this capability moved to the
interceptor
object held by the session, which is immutable after creating the session. However, when constructing a newImageDownloader
, it is not possible to pass in an interceptor for it to use when initializing its session.Nor can one pass an interceptor to the
download
API onImageDownloader
for it to attach to a specific request.Other Uses
This would also be useful for adding headers such as authentication via the request adapter API that the interceptor provides.