HTTPSocket receive progress inconsistant

I’m using Xojo.Net.HTTPSocket to download a file, In the ReceiveProgress event I have the following code:

Dim intPercentComplete As Integer = Round((BytesReceived / TotalBytes)  * 100)
System.DebugLog "Percent: " + str(intPercentComplete) + " Received: " + str(BytesReceived) + " Total: " + str(TotalBytes)

I’m getting inconsistent results. I’m always downloading the same file, but sometimes it works correctly, and sometimes I get something like this:

The Total is always correct, but the received bytes will be very high. It is incorrect more times than it is correct.

Any suggestions would be appreciated.