The goal is to get one URLSession to send request not directly to the network but to another URLSession. I need the default URLSession caching mechanism but want to get modified data in some cases (particularly I want to resize some images and let URLSession to cache that resized image data).
let urlRequest = SomeURLRequestChainingDecorator() //The goal
let urlRequest = URLRequest(url: url)
let (proxiedImageData, _) = try await urlSession.data(for: urlRequest) //mark 1
image = UIImage(data: proxiedImageData, scale: scale)
//mark 1:
//Need intermediate task here to do image resizing and encode back to Data before URLSession will get the response
var image = UIImage(data: originalData, scale: scale).resize()
return image.jpegData(compressionQuality: 0.5)