totalBytesExpectedToRead returns -1 even Content-length has a value
I found the same problem here on stackoverflow but was not answered
Here's my code:
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
}
Server response:
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
Result:
totalBytesRead: 1211
totalBytesExpectedToRead: -1