Getting total file length when using chunked http transfers

妖精的绣舞 提交于 2019-12-22 01:09:11

问题


I've written a program in Java to use chunking to download large files over http. Everything is working fine but I'd like to add a progress bar which I can't do unless I get the total length of the file. Is there any way to do this?


回答1:


If the server provides a Content-Length header field, then that's easy. If it doesn't, then you're out of luck.

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



来源:https://stackoverflow.com/questions/6285024/getting-total-file-length-when-using-chunked-http-transfers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!