This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading chunked data from socket.  RSS feed

sudh sasi
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In http response header I am seeing "Transfer-Encoding: chunked". Each chunk comes with a header indicator on the length of chunk. While reading response from socket and appending it to string buffer, the chunk header is also getting in as part of response. How to avoid this unwanted part (Chunk length) from getting to my final response string.
Here is the code that I use to read response from socket.

byte[] buf = new byte[1024];
while ((i = > -1) {
String s = new String(buf, 0, i);
Alexandre de Paula
Posts: 8
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!