【发布时间】:2016-03-27 15:33:55
【问题描述】:
我正在使用 alamofire 处理 http 请求,但我发现 alamofire 只接受 200 到 299 之间的一系列 http 响应状态码。有没有办法自定义可接受的状态码?下面是我添加的带有自定义返回代码范围的代码,但它不起作用。响应代码是 10050。你能告诉我我是否遗漏了什么吗?
let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
configuration.timeoutIntervalForResource = 10 // seconds
configuration.timeoutIntervalForRequest = 10
let manager = Alamofire.Manager(configuration: configuration)
manager.request(.POST, "http://localhost:880/login",
parameters:["mobile" : mobile, "password" : password],
encoding: .URL)
.validate(statusCode: 200..<50000)
.response(queue: dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), completionHandler: {
(request, response, data, error ) in
completeHandler(data, response, error)
})
【问题讨论】: