简体   繁体   中英

different timeout for different request with Alamofire

I'm using Alamofire to consume web services in iOS, my question is whether if it's possible to have different timeouts with Alamofire in different request to web services.

The method:

let configuration = URLSessionConfiguration.default
configuration.timeoutIntervalForRequest = 10

It works well, I wonder if, in order to have two different timeouts, it's necessary to have two different instances of a Client (?)

Setting request timeout on a per-request basis can be done by generating your own URLRequest values with custom timeoutInterval s set, or by adopting Alamofire's URLRequestConvertible protocol and use a more CRUD-like modeling for your APIs to produce URLRequest s which are performed by Alamofire. We outline such an approach in our Advanced Usage documentation . (Note that that document will be updated for the Alamofire 5 update soon.)

You have to use various session managers or change current manager configuration

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM