简体   繁体   中英

Android - Header content-length equal -1

I'm downloading a file in my android app and I want to display a progressbar. I need to know the total file size by using this method : here . The problem is that I always get -1 despite the fact that it's set on the server and I can see it from my computer.

This is the code :

URL url = new URL(fileUrl);
URLConnection ucon = url.openConnection();
ucon.connect();
int length = ucon.getContentLength();

What is the problem ?

这与Android无关,很可能不是从服务器发送的。请使用任何嗅探工具以确保内容长度标头存在。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM