2

When I print out the expected bytes from an Alamofire progress call it always prints -1 until the very end, when it prints the total. However, if I run a curl command against the webserver I get header output which very clearly lists the Content-Length header.

Why is it always saying -1?

Gargoyle
  • 9,590
  • 16
  • 80
  • 145

1 Answers1

0

Try this,

Pass Accept-Encoding key in header.

It worked for me.

let headers = ["Accept-Encoding" : ""]

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
        }

Original answer

Ravi
  • 93
  • 11