我尝试从标头响应中检索值,但似乎无法检索此值?我曾尝试使用allHeaderFields
,但似乎不是NSURLResponse
的成员?
testProvider.request(.SignIn(email, password), completion: { result in
switch result {
case let .Success(response):
do {
try response.filterSuccessfulStatusCodes()
let data = try response.mapJSON()
}
catch {
// show an error to your user
}
case let .Failure(error):
print(error)
let description = "Error! Please check your internet connection"
delegate.loginProvider(self, didError: description)
}
})
答案 0 :(得分:0)
使用此闭包,您可以使用response?.allHeaderFields
获得收到的标头。
Alamofire.request(.GET, "https://httpbin.org/get", parameters: ["foo": "bar"])
.response { request, response, data, error in
print(request?.allHTTPHeaderFields)
print(response?.allHeaderFields)
print(data)
print(error)
}