for timeout use timeoutInterval
for a specific url or request.
if let url = NSURL.init(string: "YOUR_URL") {
var request = URLRequest(url: url as URL)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
if let myUrl = NSURL.init(string: "SPECIFIC_URL"),
myUrl.isEqual(url) {
request.timeoutInterval = 10 // 10 secs
}
let postString = "param1=\(var1)¶m2=\(var2)"
request.httpBody = postString.data(using: .utf8)
Alamofire.request(request).responseJSON { response in
/// handle response here
}
}
according to git hub validate() checks for the status codes are within the 200..<300
range, and that the Content-Type
header of the response matches the Accept
header of the request, if one is provided.