Reputation: 11
For my app I send a http-get request through a socket. Then de website sends a respone, but it is using chunked encoding. Is there a way to download the full data? Maybe I use the wrong way the download the data?
BufferedReader rsp = new BufferedReader(new InputStreamReader(Client.getInputStream()));
I have read about 'ChunkedInputStream', but I can't get it work.
Upvotes: 1
Views: 2472
Reputation: 311054
Use an HttpURLConnection instead of a Socket. Does it all for you.
Upvotes: 2
Reputation: 48226
specification of chunked encoding is here
in other words read until first "\r\n"
and parse the number with radix 16 then read until you have read that many bytes and another "\r\n"
(which is not part of the data) and repeat until the number equals 0
Upvotes: 1