But this is part of my report Khaled, I cannot use .size because it returns 0 because the API is removing the content length. Another thing is that the output file is not created in this case. It seems rather strange that the API would be so that you cannot get the length
The output file is not created? That is odd. When I run your above scripts, the file is downloaded correctly. Can you please test this again? As for .size, sorry, I meant .rcvd, which returns the total bytes received.
It seems rather strange that the API would be so that you cannot get the length
If you find a way around it, let me know. As far as I can tell, it is an API bug. The API that enables gzip/deflate decoding in WinINet, but disables content-length in the header, is InternetSetOption() with the INTERNET_OPTION_HTTP_DECODING option. If INTERNET_OPTION_HTTP_DECODING is not set, content-length is present as expected.
Remember that content-length is the size of the transfer, so if the transfer encoding is gzip/deflate, it will be the compressed transfer size, not the size of the received file, which is in .rcvd.