1

i used RetryPolicy in my code with this class:

open class ConnectionLostRetryPolicy: RetryPolicy {
    public init(retryLimit: UInt = RetryPolicy.defaultRetryLimit,
                exponentialBackoffBase: UInt = RetryPolicy.defaultExponentialBackoffBase,
                exponentialBackoffScale: Double = RetryPolicy.defaultExponentialBackoffScale,
                retryableHTTPMethods: Set<HTTPMethod> = RetryPolicy.defaultRetryableHTTPMethods) {
        super.init(retryLimit: retryLimit,
                   exponentialBackoffBase: exponentialBackoffBase,
                   exponentialBackoffScale: exponentialBackoffScale,
                   retryableHTTPMethods: retryableHTTPMethods,
                   retryableHTTPStatusCodes: [],
                   retryableURLErrorCodes: [.networkConnectionLost])
    }

    public func adapt(_ urlRequest: URLRequest, for session: Session, completion: @escaping (Result<URLRequest, Error>) -> Void) {
        print("TEST")
    }
}

and i want to adapt per request to change timeout time. but adapt func does not called. what should i do?

i used it like this:

let alamofire = AlamofireSession.shared
alamofire.session = Session(interceptor: ConnectionLostRetryPolicy())
Sajjad
  • 1,536
  • 2
  • 17
  • 31
  • Try to replace `Result` with `Swift.Result`? https://stackoverflow.com/questions/58852844/alamofire-5-0-0-rc-3-requestinterceptor-adapt-method-not-being-called-of-alamofi ? – Larme Dec 29 '22 at 20:39

1 Answers1

0

This looks like some sort of wrapper for Alamofire, as AlamofireSession isn't something Alamofire provides. An Alamofire Session has an underlying .session, which is the URLSession. I suggest you look into whatever wrapper you're using.

Jon Shier
  • 12,200
  • 3
  • 35
  • 37