Is it possible to set different expiration timeout for each request?
The only way I found was to create a new NSURLSession with a different NSURLSessionConfiguration and change the timeoutIntervalForResource
. Same thing with frameworks like Alamofire.
You absolutely can do this. You can set the value directly on an NSMutableURLRequest
which can be passed into Alamofire.
let URL = NSURL(string: "https://httpbin.org/get")!
let mutableURLRequest = NSMutableURLRequest(URL: URL)
mutableURLRequest.timeoutInterval = 5.0
Alamofire.request(mutableURLRequest)
.responseJSON { response in
debugPrint(response)
}
You cannot control the timeoutIntervalForResource
per request. The timeout interval property on NSURLRequest
is equivalent to timeoutIntervalForRequest
on the NSURLSessionConfiguration
. More details here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With