Getting the total file length when using transmitted http transmissions

I wrote a Java program to use chunking to upload large files via http. Everything works fine, but I would like to add a progress bar, which I can’t do if I don’t get the total file length. Is there any way to do this?

0
source share
1 answer

If the server provides a header field Content-Length, then this is easy. If this is not the case, you are out of luck.

Reasonable server implementations provide Content-Lengthwhen the content is static and has a known size. If the content is dynamically generated, it is impossible to know the length a priori, at least without making two passes through the data.

0

All Articles