简体   繁体   中英

Content-Length header is not getting in Android 2.3 above browser

I am having an hybrib application in that in that a simple php page will open which contents some link of files, and from my android wrapper i have implemented the download functionality of file.

So for user convenience i am showing the length and progress of download while the file is downloading for that my application server has set a content-length header to pass the size on device, but the problem I am facing is surprising. The file length is working fine in Android 2.2. I am getting the content header correctlt but in Android 2.3 above I am getting the content length for smaller files but for the larger file I am not even getting the Header Field.

con.getHeaderField("content-length");

returning me null in case of Android 2.3 above.

So is there any limitation of size for the User Agent above 2.3 because if it is working fine in 2.2 means there is no problem at server end it is the problem only on device user agent.

Update

I have tried it with different size of files and it is working fine till 60KB in Android 2.3 above as well.

It sounds like the client may be chunking the file. Check for the presence of the following header:

Transfer-Encoding: chunked

If that exists, the request is chunked and you will not get a Content-Length header.

See http://en.wikipedia.org/wiki/Chunked_transfer_encoding for more details.

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