【发布时间】:2017-02-12 07:25:22
【问题描述】:
即使 Content-length 有值,totalBytesExpectedToRead 也会返回 -1
我在 stackoverflow 上找到了相同的 problem 但没有得到答复
这是我的代码:
Alamofire.download(.POST, urlString, headers: headers, destination: destination)
.progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
print("totalBytesRead: \(totalBytesRead)")
print("totalBytesExpectedToRead: \(totalBytesExpectedToRead)\n\n")
}
.response { request, response, data, error in
}
服务器响应:
Access-Control-Allow-Origin →*
Access-Control-Expose-Headers →Link
Connection →keep-alive
Content-Length →163
Content-Type →application/json; charset=utf-8
Date →Tue, 04 Oct 2016 07:12:56 GMT
结果:
totalBytesRead: 1211
totalBytesExpectedToRead: -1
【问题讨论】: