dmytro-anokhin / url-image

AsyncImage before iOS 15. Lightweight, pure SwiftUI Image view, that displays an image downloaded from URL, with auxiliary views and local cache.
MIT License
1.11k stars 96 forks source link

Http Header fields #121

Closed Uppalled closed 3 years ago

Uppalled commented 3 years ago

On version 1 we used to pass a URLRequest and could easily set up any necessary header fields when initializing it, is there a way currently to add a header? If not can add it as another var on URLImageOptions and pass it to the URLSessionCoordinator

dmytro-anokhin commented 3 years ago

Implemented in 2.1.11. You can set it using Download.URLRequestConfiguration object (need to import DownloadManager module):

let configuration = Download.URLRequestConfiguration(allHTTPHeaderFields: [ "Field Name" : "Value" ])
let options = URLImageOptions(urlRequestConfiguration: configuration)

Can also be set globally:

URLImageService.shared.defaultOptions.urlRequestConfiguration.allHTTPHeaderFields = [
    "Field Name" : "Value"
]