我正在使用AFNetworking 3.0与session manager
这样:
sessionManager = AFHTTPSessionManager(baseURL: baseURL)
sessionManager?.post(url, parameters: parameters, progress: nil,
success: {(task: URLSessionDataTask, responseObject: Any) in
print(task?.response)
, failure: {(task: URLSessionDataTask?, error: Error) in
print(task?.response)
})
当我打印task.response
对象时,我只得到标题。如何从服务器获取完整的响应字符串和错误(如果有的话)?
答案 0 :(得分:0)
你可以试试这个
print(responseObject.response)
print(responseObject.response.request) // original URL request
print(responseObject.response.response) // URL response
print(responseObject.response.data) // server data
print(responseObject.response.result) // result of response serialization